Commit 2c68396
authored
fix: allow className and style props to coexist when properties differ (#223)
* fix: allow className and style props to coexist when properties differ
Previously, when both className and style props were provided, className-derived
styles would be completely overwritten by inline styles due to Object.assign()
behavior in deepMergeConfig().
This refined solution:
- Only creates style arrays when className and inline styles have non-overlapping properties
- Maintains CSS precedence rules (inline styles override className for same properties)
- Preserves backward compatibility with existing behavior
- Passes all existing tests while enabling the new functionality
Enables combining NativeWind className styling with React Native Reanimated
animated styles when they target different CSS properties.
Fixes issue where className was ignored when style prop was also present,
while preserving expected CSS specificity behavior.
* perf: optimize style merging performance and readability
Address code review feedback by improving the style merging logic:
- Remove Set creation and array spreading for better performance
- Add early exit when finding non-overlapping properties
- Simplify logic flow making it more readable and maintainable
- Maintain identical functionality while reducing computational overhead
Performance improvements are especially beneficial for components
with many style properties, reducing unnecessary object iterations.1 parent 8a01f75 commit 2c68396
File tree
2 files changed
+83
-1
lines changed- src
- __tests__/native
- native/styles
2 files changed
+83
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
139 | 173 | | |
140 | 174 | | |
141 | 175 | | |
| |||
0 commit comments