Conversation
|
|
||
| if (typeof viewRef._component.setNativeProps === 'function') { | ||
| viewRef._component.setNativeProps({ style: rawStyles }); | ||
| setNativeProps(viewRef._component, rawStyles); |
There was a problem hiding this comment.
Shouldn't this be viewRef.current._component?
I was trying to use with next.js and while debugging viewRef._component is always undefined
@piaskowyk
There was a problem hiding this comment.
Sorry, I thought I installed 2.2.4
|
I'm seeing this bug on @piaskowyk Is it possible If I revert back to diff --git a/node_modules/react-native-reanimated/lib/reanimated2/js-reanimated/index.web.js b/node_modules/react-native-reanimated/lib/reanimated2/js-reanimated/index.web.js
index 76e1dc0..46aa7bf 100644
--- a/node_modules/react-native-reanimated/lib/reanimated2/js-reanimated/index.web.js
+++ b/node_modules/react-native-reanimated/lib/reanimated2/js-reanimated/index.web.js
@@ -11,7 +11,22 @@ export const _updatePropsJS = (_viewTag, _viewName, updates, viewRef) => {
acc[index][key] = value;
return acc;
}, [{}, {}]);
- viewRef.current._component.setNativeProps({ style: rawStyles });
+ if (typeof viewRef.current._component.setNativeProps === 'function') {
+ viewRef.current._component.setNativeProps({ style: rawStyles });
+ } else if (Object.keys(viewRef.current._component.props).length > 0) {
+ Object.keys(viewRef.current._component.props).forEach((key) => {
+ if (!rawStyles[key]) {
+ return;
+ }
+ const dashedKey = key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());
+ viewRef.current._component._touchableNode.setAttribute(
+ dashedKey,
+ rawStyles[key]
+ );
+ });
+ } else {
+ console.warn('It is not possible to manipulate component');
+ }
}
};
global._setGlobalConsole = (_val) => { |
|
@nandorojo with next.js, mount animations with a settimeout around 200ms. With initial render I too saw the same error |
|
This is also breaking for me on web with the same error as @nandorojo with this component which only uses View and Text. Works on 2.2.3 |

Description
setNativePropsmethod 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#1935Changes
setNativePropscallScreenshots / GIFs
Before
before.mov
After
after.mov