fix: preserve component props when className.target is false
#226
+57
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #229
Summary of changes
If the mapping for
className.targetis configured to "false" (like the case of theButtonoverride from RN), the component won't preserve the props.Details
When importing the
Buttoncomponent fromreact-native, it loads the following file:react-native-css/src/components/Button.tsx
Lines 11 to 25 in 008d479
Where the
target: falsemapping is passed through:->
useCssElement->
useNativeCss(mapped to config)->
getStyledProps(state.configs[x])->
deepMergeConfig-> else block on
if (config.target) { ... }:https://github.com/nativewind/react-native-css/blob/008d479253365745acedef5a9602a7382f991597/src/native/styles/index.ts#L364C2-L367
which results in empty prop object for the Button if just using like the following: