You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I evaluate selectedItem() or selectedIndex() as part of the onChangeText callback, it is returning the previous value, not the new value. I have an id and a value in my data items so just the text value is not enough. The only way I can get the new id is to put a timeout in, 1000ms is enough but 100ms isn't, so I imagine it's waiting for animation to finish (even if I put an animationDuration of 0 in, it's still animating the ripple slowly)
<Dropdown
labelFontSize={0}
ref='picker'
data={data}
value={this.state.value}
onChangeText={(value) => {
console.log(value); // gives new value OK
setTimeout(() => {
let me = this.refs['picker'];
console.log('selected item', me.selectedItem(), me.selectedIndex()); // gives previous item & index
}, 100);
}}
animationDuration={0}
/>
I don't want to have to search in my data by value just to get the id, and I need the new id immediately upon selection. Is there a workaround or fix?
The text was updated successfully, but these errors were encountered:
JeremyBradshaw7
changed the title
selectedItem() giving old value
selectedItem() giving previous value in onChangeText handler
May 11, 2018
When I evaluate selectedItem() or selectedIndex() as part of the onChangeText callback, it is returning the previous value, not the new value. I have an id and a value in my data items so just the text value is not enough. The only way I can get the new id is to put a timeout in, 1000ms is enough but 100ms isn't, so I imagine it's waiting for animation to finish (even if I put an animationDuration of 0 in, it's still animating the ripple slowly)
I don't want to have to search in my data by value just to get the id, and I need the new id immediately upon selection. Is there a workaround or fix?
The text was updated successfully, but these errors were encountered: