Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I trigger when a specific button is pressed in react-native-picker-select?

I am using react-native-picker-select. When there is data called ingre, I want ingrebool to be false when a,b,c,d is pressed and to be true when e is pressed. What should I do?

this is my code

            export const ingre = [
                { label: 'a', value: 'Tangerinefeed' },
                { label: 'b', value: 'dryexamfeed' },
                { label: 'c', value: 'wetfeed' },
                { label: 'd', value: 'sawdust' },
                { label: 'e', value: 'etc' },
            ];



            
            export const ArrowIconPickerObj = ({ingre }) => {
            const [ingrebool, setIngrebool] = useState(false)
                return (
                    <RNPickerSelect
                        items={ingre}
                    />
                )

            }

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You figured it out yourself already: Set ingrebool to be false when a,b,c,d is pressed and to be true when e is pressed.

 <RNPickerSelect
   items={ingre}
   onValueChange={value => setIngrebool(value === "etc")}
 />
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading