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

ReactComponent.propTypes is undefined when dynamically inject the react build js #5

Closed
satty1987 opened this issue May 17, 2020 · 7 comments
Assignees
Labels
accepted Accepted for development bug Something isn't working

Comments

@satty1987
Copy link

satty1987 commented May 17, 2020

image
Fix this by adding null check.

@justinbmeyer
Copy link
Member

justinbmeyer commented May 17, 2020

Thanks! Just to make sure I am understanding what is happening and how to test it ... you are dynamically addicting React after this library is installed?

@laddhoffman
Copy link

Looks like I am encountering this as well.
Uncaught TypeError: right-hand side of 'in' should be an object, got undefined
I tried this same approach in #6 but then realized there's some other disconnect here. This solution just masks another problem. I get the same error when I pass in an instance of React.Component or React.FC, with or without props defined. And if I add this undefined check it gets past that and loads the component, but it's not getting props at all.

@laddhoffman
Copy link

Oh I see, this package is perhaps assuming we are using propTypes, now https://www.npmjs.com/package/prop-types.
But I am using TypeScript so I have no need for propTypes.

@laddhoffman
Copy link

Re-opened #6

@justinbmeyer
Copy link
Member

Ah, so ReactComponent doesn't always have propTypes. Thanks!

@leanderseige
Copy link

I think I had a similar issue and solved it like this:

window.addEventListener('DOMContentLoaded', (event) => {
  var root = document.getElementById("id")
  var mywc = document.createElement('mywc')
  mywc.settings = "settings"
  root.appendChild(mywc)
}

@christopherjbaker christopherjbaker added bug Something isn't working accepted Accepted for development labels May 20, 2022
@janebitovi janebitovi self-assigned this Aug 9, 2022
@christopherjbaker
Copy link

We adjusted the logic in #50 to allow an alternate prop definition besides propTypes. We cannot current get around the need for a minimal props definition at runtime, however.

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

No branches or pull requests

6 participants