BUGFIX cssInterop only triggering when a param is passed by kimchouard · Pull Request #768 · nativewind/nativewind · GitHub
Skip to content

BUGFIX cssInterop only triggering when a param is passed#768

Open
kimchouard wants to merge 3 commits intonativewind:mainfrom
kimchouard:cssinterop-fix
Open

BUGFIX cssInterop only triggering when a param is passed#768
kimchouard wants to merge 3 commits intonativewind:mainfrom
kimchouard:cssinterop-fix

Conversation

@kimchouard
Copy link
Copy Markdown
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 🤓

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 25, 2024

@dannyhw
Copy link
Copy Markdown
Contributor

dannyhw commented Jan 25, 2024

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

@kimchouard
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

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

@marklawlor
Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Contributor Author

It's only affecting Web.

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

@danstepanov
Copy link
Copy Markdown
Member

@danstepanov danstepanov added the question Further information is requested label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants