-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
setNativeProps
ignores previous style changes
#1935
Comments
Sure, you can make a PR. Just be aware that the behavior of setNativeProps is undefined in RN and complicated to implement on web. |
This patch is available in 0.15.2 |
Thank you both for the quick fix here. |
Re-opening as the patch caused a regression and has been reverted in 0.15.7 |
This will be very hard if not impossible to match react native. The good news is that this API will eventually be deprecated and removed from RN. The bad news is that the way React DOM updates, combined with the way RN style is converted to RDOM className + style, means that React DOM updates won't always clear away styles set using setNativeProps. Ideally an API like this would be integrated with the platform renderer. Same is true for touching the DOM outside of render, e.g., during style injection. I've brought this up many times with the React team but there is no progress because they're all focused on trying to get concurrent mode out. Ultimately, I think React DOM is not the ideal renderer, but we need to use it for compat with the existing ecosystem. One day we might be able to build a new renderer with no backwards compat for React DOM and it would be a lot more efficient and powerful |
`transform` animation value is not preserved between render on mobile. This is the reason that `scale` is return to origin when writing a text on `textInput` which invokes `re-render`. So I changed animation value from `scale` to `width` and `height`. But there is a bug about `withSpring` function on `web`, then I splits an animation value according to platform. This bug seems to have related with `react-native-web`. You can check relate issue with [here](software-mansion/react-native-reanimated#1804) or [here](necolas/react-native-web#1935).
setNativeProps method was ignoring previously changed style, so before the method call, I merge the current style with the previous one to overcome this issue. Detailed description: necolas/react-native-web#1935
`transform` animation value is not preserved between render on mobile. This is the reason that `scale` is return to origin when writing a text on `textInput` which invokes `re-render`. So I changed animation value from `scale` to `width` and `height`. But there is a bug about `withSpring` function on `web`, then I splits an animation value according to platform. This bug seems to have related with `react-native-web`. You can check relate issue with [here](software-mansion/react-native-reanimated#1804) or [here](necolas/react-native-web#1935).
@piaskowyk can you think of an alternate solution for Reanimated, since it sounds unlikely that this patch will be in RNW? Currently, Reanimated only functions properly with RNW 0.15.2 - 0.15.6. This is difficult for web adoption. Could reanimated internally keep track of the previous value it passed to |
Reanimated now has an updated version that sort of solves this internally. So you could probably close this issue. However, Reanimated on Web still has its occasional bugs, namely for springs or styles that update after a component gets unmounted/remounted. It's possible these are bugs I should open on the Reanimated repo. But they feel more like race conditions that come about from the use of Given the limitations of RNW exposes the DOM I'm asking a bit naïvely, since there may be some obvious reasons not to do that. |
Yeah, use 2.2.3. 2.2.4 is broken on web I think. |
Previously deprecated, and not supported in the React Native Fabric architecture. Close #1935
Previously deprecated, and not supported in the React Native Fabric architecture. Close #1935
Previously deprecated, and not supported in the React Native Fabric architecture. Close #1935
Previously deprecated, and not supported in the React Native Fabric architecture. Close #1935
setNativeProps method was ignoring previously changed style. Close necolas#1939 Fix #necolas#1935
Previously deprecated, and not supported in the React Native Fabric architecture. Close #1935
The problem
Update
react-native-web
from0.12.3
to0.13.0
brokesetNativeProps
function, and next callsetNativeProps
override previously applayed style.For example. I have component:
I want to change the style of the component.
Operation:
Result in version
0.12.3
:view style = { width: 200, height: 200 }
Result in version
0.13.0
(and newer):view style = { width: 100, height: 200 }
How to reproduce
Just run both apps
Example in version
0.12.3
: https://codesandbox.io/s/rnw-12-y11uyExample in version
0.13.0
: https://codesandbox.io/s/rnw-13-sbutoSteps to reproduce:
Expected behavior
I expect behavior like was in version
0.12.3
Environment (include versions). Did this work in previous versions?
Additional context
In
react-native-reanimated
we usesetNativeProps
to apply changed style during an animation. But after upgradereact-native-web
, we have strange issues on the web version if one animation is longer than another component back to the initial style.Example issue:
I made a little investigation and confirmed that
setNativeProps
doesn't change the initial styles of component:react-native-web/packages/react-native-web/src/modules/usePlatformMethods/index.js
Lines 29 to 40 in c47bec7
I can prepare PR to apply changes to the initial style, but I'm not sure how this can affect other components.
Thanks for any help!
The text was updated successfully, but these errors were encountered: