-
-
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
Check value callback whether it is valid or not #5784
Check value callback whether it is valid or not #5784
Conversation
TypeError: right operand of 'in' is not an object TypeError: Cannot convert undefined value to object
Hey @vietdung97, thanks for submitting this PR! Just out of curiosity, could you please also share the code snippet that causes this error? We'd like to know how this error can be triggered from the user code. |
@tomekzaw this error appears on passing array with falsy condition or null or undefined element. import { StyleSheet } from 'react-native';
import Animated from 'react-native-reanimated';
const styles = StyleSheet.create({
style1: {
flex: 1,
},
style2: {
backgroundColor: '#ff0000',
},
});
function Sample(): JSX.Element {
// case 1
const condition = false;
return (
<Animated.View style={[styles.style1, condition && styles.style2]} />
);
// case 2
return (
<Animated.View style={[styles.style1, null]} />
);
// case 3
return (
<Animated.View style={[styles.style1, undefined]} />
);
}
export default Sample; |
@NikitaDudin Thanks! |
Here is my sample code. It appear due to animation entering={FadeIn}>. I try to removing this props then my project works normally
I don't have problems with style contains falsy conditions or null or undefined elements, @NikitaDudin
|
I got this error with latest version of rnr |
@vietdung97 you right, this error appears for styles array with falsy(null, undefined, false) element when set entering animation import { StyleSheet } from 'react-native';
import Animated, { FadeIn /* or other entering animation */ } from 'react-native-reanimated';
const styles = StyleSheet.create({
style1: {
flex: 1,
},
style2: {
backgroundColor: '#ff0000',
},
});
function Sample(): JSX.Element {
// case 1
const condition = false;
return (
<Animated.View entering={FadeIn} style={[styles.style1, condition && styles.style2]} />
);
// case 2
return (
<Animated.View entering={FadeIn} style={[styles.style1, null]} />
);
// case 3
return (
<Animated.View entering={FadeIn} style={[styles.style1, undefined]} />
);
}
export default Sample; cc @tomekzaw |
Hi @vietdung97! Thanks for this PR! I've looked at it with @piaskowyk and we decided that it will be better to use If you could add componentStyleFlat = componentStyleFlat.filter(Boolean); after |
Hi @m-bert , I've made changes to my PR based on your comments. I believe it now addresses the feedback and would be happy if it's accepted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing that ❤️
TypeError: right operand of 'in' is not an object ![image](https://github.com/software-mansion/react-native-reanimated/assets/50390141/a37e35de-e8a0-49b5-ba04-75cea807be19) TypeError: Cannot convert undefined value to object ![image](https://github.com/software-mansion/react-native-reanimated/assets/50390141/e9e10f0e-887a-4b27-a9f9-d6ce58bb3ea3) <!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary <!-- Explain the motivation for this PR. Include "Fixes #<number>" if applicable. --> ## Test plan <!-- Provide a minimal but complete code snippet that can be used to test out this change along with instructions how to run it and a description of the expected behavior. --> --------- Co-authored-by: Michał Bert <63123542+m-bert@users.noreply.github.com>
TypeError: right operand of 'in' is not an object
TypeError: Cannot convert undefined value to object
Summary
Test plan