Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problems with useRef #490

Open
njavilas2015 opened this issue Sep 17, 2022 · 1 comment
Open

problems with useRef #490

njavilas2015 opened this issue Sep 17, 2022 · 1 comment

Comments

@njavilas2015
Copy link

njavilas2015 commented Sep 17, 2022

good I am using react and preact in a component which is a simple input when using useRef it generates errors

import { Ref, useEffect, useRef, useState } from "preact/hooks";
import { styled } from "goober";

const Video = styled('video')`

`

const App = () => {

  const elementRef: Ref<HTMLVideoElement | null> = useRef<HTMLVideoElement | null>(null)

  useEffect(() => {

    const element: HTMLVideoElement | null = elementRef.current // DOM Ref

    console.log(element)
  }, [])

  return (
    <div>

      <Video ref={elementRef} >

    </div >
  )
}

export default App

if I don't use goober it works, but when I incorporate it as in the example, there is no reference

more info
I made a comparison between goober and style in line and I observed differences that perhaps the error occurred

with goober
image

without goober
image

@jjjtoikka
Copy link

jjjtoikka commented Oct 20, 2022

I got it working like this

export const StyledContainer = styled(
  'div',
  React.forwardRef
)<Props>((props) => {...styles});

in your case just

const Video = styled('video', React.forwardRef)``

Cheers, J

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants