componentsToHints breaks if PlayRoomProps.components
file contains something other than a component
#259
Labels
PlayRoomProps.components
file contains something other than a component
#259
Request
Could a condition/filter be added to guarantee that an object is passed to
parsePropTypes
? Actually, not 100% sure of the ideal approach... would need to dig deeper, but here in lies the problem 👇Why
playroom/src/utils/componentsToHints.ts
Line 26 in 1b996eb
If I'm understanding this correctly,
components
👆 are derived from whatever file location is passed to thePlayroomProps['components']
setting. So if acomponents
file contains even 1 export that isn't a viable component with props, this line breaks e.g. aProxy
likechakra-factory
.If that
Proxy
is one of the many components exported fromPlayroomProps['components']
... afunction
will indeed get passed toparsePropTypes
and that function will fail because it is expecting an object as an argument and doesn't have a fail-safe.The thing is, the argument for
parsePropTypes
is strictly typed to require an object, so it sorta makes sense to me to ensure the argument passed into it is conditioned for passing the acceptable type. Rather than assuming allexports
fromPlayroomProps['components']
are definitely component types.Right now, the project I'm maintaining that has this issue has a large
components/index
and it would be a pain the neck if we had to automate creating a second file—less a few exports—just to ensure playroom doesn't break.P.S.
If anything is unclear, I'd be happy to elaborate. I can also raise a PR if that makes things easier.
The text was updated successfully, but these errors were encountered: