In my React Native app, I'm trying to push a realm object to another screen using wix's react-native-navigation through passProps
. Here is my code:
in render()
render () {
var entry = this.props.entry // this is a realm object
return (
<Text onPress={() => this.gotoEdit(entry)}>EDIT</Text>
)
}
the gotoEdit function:
gotoEdit (entry) {
this.props.navigator.push({
screen: 'app.EditEntry',
title: 'EDIT',
passProps: {entry} // when this line is removed, the navigator works fine
})
}
However, "EDIT" is tapped, the app crashes. I get this message in the React Debugger:
'getOwnPropertyDescriptor' on proxy: trap returned descriptor for property '0' that is incompatible with the existing property in the proxy target
I figured it out. You can't push Realm objects as props to another screen without it crashing. The solution is to pass an identifying property of the object, e.g. ID, and then use that to reference the object in the next screen.