react-native-picker / picker

Picker is a cross-platform UI component for selecting an item from a list of options.
MIT License
1.49k stars 280 forks source link

ref.current returns null or undefined #375

Open ur-gh opened 2 years ago

ur-gh commented 2 years ago

Dev Env: EXPO - WEB useRef followed by assigning ref to Picker returns null or undefined ( however it was initialized ).

Originally, I was trying to disable the left and right arrows from changing the picker values. Decided to see if ref use will somehow help only to find ref is not being set.

example code: const r = React.useRef(); useEffect(() => { console.log(r.current); //remains undefined here }, []);

. . . <Picker ref={r} selectedValue={userFilter} style={{ width: 150 }}

            >

...

LucioChavezFuentes commented 2 years ago

I also have this issue on Web but I open a pull request that fixes this problem, I hope it can be reviewed soon.