mobx: Dynamic observable cannot be frozen.
This issue also refers to this one #1881 I am having the following issue and it can be recreated as follows:
The allVehicles variable is an array of string IDs;
@observable allVehicles;
@action setAllVehicles(vehiclesID) {
this.allVehicles = vehiclesID;
}
}
Then here the VehiclesStore.setSelectedObject sets the selectVehicle to an observable variable inside the VehiclesStore, based on the vehicleID i find witch vechicle from VehiclesStore.objects i need to have selected. The VehiclesStore.objects is also an observable array of objects
selectVehicle(vehicleID) {
let selectVehicle = VehiclesStore.objects.find(vehicle => vehicle.id === vehicleID);
VehiclesStore.setSelectedObject(selectVehicle);
}
Based on the allVehicles observable i’m creating a list of PickerItems like so,
The value of one entry of the allVehicles array looks like this:
<Picker.Item key = {'myID'} value = {'vehicleID'} label = {'Plate'}/>
<Picker
style = {{ width: '100%' }}
mode = { "dropdown" }
prompt = {"Select a vehicle"}
onValueChange = {(vehicleID) => {
console.log(vehicleID); **THIS IS NEVER REACHED**
this.selectVehicle(vehicleID);
this.props.props.navigate('Details', {props: this.props});
}}
>
{VehiclesStore.allVehicles}
</Picker>
I hope that this information it’s helpful.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (6 by maintainers)
At first glance it sounds like you are pasisng observable data to Picker where you shouldn’t, since it doesn’t understand them. Try to
toJSyour value firstOp ma 11 feb. 2019 om 09:58 schreef itamar sharify <notifications@github.com