-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Cannot add new property '__reanimatedHostObjectRef' #1517
Comments
Issue validator - update # 4Hello! |
I don't think we should handle problems that come from unmerged changes. If you have issues with the code from that PR, please mention them there. Once it's merged and the problem persists, please reopne this issue or open the new one. Thank you 🙏 |
@rpavlovs are you still experiencing this issue? Can you confirm that it actually does work with JSC, but doesn't work with Hermes? |
Hey @mrousavy, it's NOT certain that this is coming from your PR. I haven't tried Reanimated 2 with JSC at all since logs are not usable with out setup. You can check if this is still an issue by having a deeply nested object coming from props, that later gets mutated inside a worklet. |
I also having this issue, when i am trying to console.log(listRef) ref of a listview. |
I also got the same error when using react-native-reanimated-carousel. |
I have made the following experience, but I can not say for sure yet if it is directly related to RA2: When you send an Object that is used within RA2 to a native Module, it will crash, emitting this exact error. Tested this with RA2.4.0 |
Cool, Maybe you can provide a minimal reproducible repository. |
I just got this error with react-native-bottom-sheet on react-native-v8:
I'm on reanimated v2.2.2. |
I currently do not have too much time, I'll try to provide one asap. |
@karol-bisztyga @dohooo @braandl @rpavlovs Here's a repo reproducing the bug: https://github.com/yairopro/reanimated-2-playground I may be wrong but the bug seems to come from trying to access freezed objects from inside worklet. |
@yairopro Thank you very much! you might me right with the freeze-assumption, or it is some other assertion made on the objects state. Either way, this ticket should be re-opened. |
@yairopro Cool! Thanks! |
I had the same issue when trying to assign an object or array of objects from Redux state to a shared value. e.g. using Redux Toolkit(RTK): // useSelector hook from RTK
const arrayOfObjects: Test[] = useSelector(selectorReturningTests);
const assignThemToMe = useSharedValue<Test[]>([]);
// Throws above error
assignThemToMe.value = arrayOfObjects; I tried using mock data and it worked just fine. It only throws error when trying to assign value returned from RTK's selector. When an object is assigned to a shared value, that object gets mutated by react-native-reanimated/Common/cpp/SharedItems/ShareableValue.cpp Lines 21 to 34 in 45c57a9
I'm assuming that it's throwing the error because it failed to mutate the object, i.e. failed to add __reanimatedHostObjRef property.
But why this issue only occurs when trying to assign data returned from RTK? Probably that's why the solution of deep copying the object/array of objects using |
Dude, you're so cool |
Hello, I was having this issue when using a value generated outside of the component in a useAnimatedStyle declaration e.g.: const data = [{ id: '1', title: 'Test', backgroundColor: 'transparent' }, { id: '2', title: 'Test another', backgroundColor: '#FF6600' }, ....etc. etc.];
const Component = () => {
const animatedBackgroundColor = useAnimatedStyle(() => {
const inputValues = data.map((_, index) => index);
const outputValues = data.map((item) => item.backgroundColor);
const backgroundColor = interpolateColor(
animatedBackgroundIndex.value,
inputValues,
outputValues,
);
return {
backgroundColor,
};
}, [animatedBackgroundIndex]);
return <Animated.View style={animatedBackgroundColor}>...etc...</Animated.View>;
}; Now moving the generation of input and output values to the component everything works correctly! const data = [{ id: '1', title: 'Test', backgroundColor: 'transparent' }, { id: '2', title: 'Test another', backgroundColor: '#FF6600' }, ....etc. etc.];
const Component = () => {
const inputValues = data.map((_, index) => index);
const outputValues = data.map((item) => item.backgroundColor);
const animatedBackgroundColor = useAnimatedStyle(() => {
const backgroundColor = interpolateColor(
animatedBackgroundIndex.value,
inputValues,
outputValues,
);
return {
backgroundColor,
};
}, [animatedBackgroundIndex]);
return <Animated.View style={animatedBackgroundColor}>...etc...</Animated.View>;
}; Hopefully this helps someone else googling this error as to what is going on. It might be worth considering a more friendly error message for this issue! |
For me this error happened when I referenced a
|
I am having the same issue, using styles from stylesheet inside usAnimatedStyle recreates the issue |
Description
I can't use an array of objects coming in through a prop inside worklets. A prop with a simple value like a number works fine. Also making a deep copy with
JSON.parse(JSON.stringify(props.items))
solves the problem.Looks like Reanimated tries to add a property on an immutable prop object and fails.
Steps to reproduce
Expected behavior
I should be able to use any type of props in worklets
Actual behavior
Package versions
The text was updated successfully, but these errors were encountered: