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

BUGFIX cssInterop only triggering when a param is passed #768

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kimchouard
Copy link
Sponsor Contributor

@kimchouard kimchouard commented Jan 25, 2024

Fixing issue #767: edge cases on prop remapping, to ensure that props are only (re)mapped if a value is passed.

E.g.: <FlatList /> only accept the columnWrapperStyle param when its numColumns param is > 1. With the current implementation of cssInterop, an empty array was passed to all remapped parameters, introducing an unexpected breaking error (Uncaught Invariant Violation: columnWrapperStyle not supported for single column lists), even though no columnWrapperStyle was set.

👉 With this proposed fix, the props are only remapped if a value is passed to the original component.

E.g.:

  • Calling <FlatList /> with no columnWrapperStyle and no numColumns (default=1) param won't trigger errors anymore.
  • If a columnWrapperStyle or columnWrapperClassName were to be added, it would be then be remapped
    BUT the end user would have also set numColumns > 1 (otherwise there is no point in calling columnWrapperStyle :).

It's my first PR on this repo, so lmk if I missed a step 🤓

Copy link

vercel bot commented Jan 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nativewind ✅ Ready (Inspect) Visit Preview Feb 5, 2024 4:46pm

@dannyhw
Copy link

dannyhw commented Jan 25, 2024

@kimchouard I think adding a description with the details of your issue would be helpful :)

@kimchouard
Copy link
Sponsor Contributor Author

@kimchouard I think adding a description with the details of your issue would be helpful :)

Indeed, thanks for raising it 😅 I've created this PR using github.dev (which I just discovered and is a complete 🤯 🤩) and all the details were in the issue #767, but I didn't realize it was not clearly showcased in here.

I've updated the description, hopefully it's more clear now! ;)

@kimchouard
Copy link
Sponsor Contributor Author

@marklawlor FYI I've integrated your latest changes from master to make this PR ready to be merged 🤓

@marklawlor
Copy link
Owner

Does this only affect web or should there be a native equivalent to this as well?

I should appreciate a unit test to demonstrate the fix. You can find some in packages/react-native-css-interop/src/__tests__/react-native-components.test.tsx that should how to test components.

@kimchouard
Copy link
Sponsor Contributor Author

It's only affecting Web.

I'll work on a unit test this week, sorry first contribution to this repo 🙏

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

Successfully merging this pull request may close these issues.

None yet

3 participants