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 React.forwardRef #137

Open
hazae41 opened this issue Feb 9, 2021 · 1 comment
Open

Problems with React.forwardRef #137

hazae41 opened this issue Feb 9, 2021 · 1 comment
Labels
✘ bug Something isn't working

Comments

@hazae41
Copy link
Member

hazae41 commented Feb 9, 2021

Hey, I face multiple errors when I use React.forwardRef

Here is my code

export const ProfileModal = forwardRef((props: {
  disconnect: () => void
}, ref: Ref<Openable>) => {
  // ...
})

The first error is that the compiled .js file modifies the "ProfileModal" variable, which is a const

Capture

I modify the script to use "let"

export let ProfileModal = ...

But then another error occurs, from the component that includes the modal

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports

const Home = () => {
  // ...

  return <>
    <ProfileModal ... />
    <... />
  </>
}

When logging ProfileModal value, it shows undefined

const Home = () => {
  // ...

  console.log("profile modal", ProfileModal)

  return <>
    <ProfileModal ... />
    <... />
  </>
}
@shadowtime2000 shadowtime2000 added the ✘ bug Something isn't working label Feb 10, 2021
@shadowtime2000
Copy link
Member

Possibly a problem with the esm.sh conversion of React but I am not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✘ bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants