question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Select View Closes When Value Changes

See original GitHub issue

Describe the bug
The select popup closes instantly when the state and selected value changes. If the value isn’t changed, it will jump back to the specified option of the value property .

To Reproduce
Steps to reproduce the behavior:

  1. Tap select
  2. Scroll to a different option (iOS)
  3. Select View disappears

Expected behavior
Select View should stay present until it is closed or “done” is tapped.

Screenshots
n/a

Additional details

  • Device: Simulator (iPhone 11, 12 Pro, etc.)
  • OS: iOS 14.3
  • react-native-picker-select version: 8.0.4
  • react-native version: 0.63.4
  • expo sdk version: n/a

Reproduction and/or code sample

<RNPickerSelect
	onValueChange={(value: number) => {
		setSelectedValue(value);
	}}
	items={[
		{ label: 'Test A', value: 0 },
		{ label: 'Test B', value: 1 },
		{ label: 'Test C', value: 2 },
	]}
	value={selectedValue}
/>

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
dioncodescommented, Jan 29, 2021

I managed to find a temporary workaround until this is fixed:

  • Remove the value prop from the <RNPickerSelect />
  • Use a ref (<RNPickerSelect ref={picker} ... />) and set the initial value (using setState) at the beginning:
const picker = useRef<RNPickerSelect>(null);

useEffect(() => {
  picker.current?.setState({ selectedItem: { label: 'Example B', value: 1 } });
}, []);

Please note that the full item (including label) needs to be passed, not only the value.

0reactions
EmmanuelSkapplecommented, Jan 19, 2021

Same problem to 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way to prevent a select menu from closing if the ...
The problem with using the click event is that I need to change the value dynamically when the ajax request finish to make...
Read more >
Retrieve records when value in column changes [closed]
I would like to get records when the Name changes (see column result). I' m not getting with this code. SELECT [Date], [Name]...
Read more >
Automating actions when a property value changes
On the Actions tab, for Actions type, select Standard. Click Create an action set to add an action set to the field. Click...
Read more >
Apply a filter to view select records in an Access database
Since the view you get after you apply a filter contains only records with the values that you selected, the rest of the...
Read more >
View/Edit Data — pgAdmin 4 6.18 documentation
The lower panel (the Data Grid) displays the data selected from the table or ... To change a non-numeric value within the grid,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found