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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

componentsToHints breaks if PlayRoomProps.components file contains something other than a component #259

Open
bigwoof91 opened this issue May 16, 2022 · 0 comments

Comments

@bigwoof91
Copy link

bigwoof91 commented May 16, 2022

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

const parsedPropTypes = parsePropTypes(components[componentName]);

If I'm understanding this correctly, components 馃憜 are derived from whatever file location is passed to the PlayroomProps['components'] setting. So if a components file contains even 1 export that isn't a viable component with props, this line breaks e.g. a Proxy like chakra-factory.

If that Proxy is one of the many components exported from PlayroomProps['components']... a function will indeed get passed to parsePropTypes 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 all exports from PlayroomProps['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鈥攍ess a few exports鈥攋ust 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.

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

1 participant