How to read props of the components in the same component?

Viewed 21

I am trying this in React Native 0.64.3:

<View nativeID="yesButton">
     <ToggleButton 
         icon="check"
         value="yes"
         onPress={(e) => getPollSelectionValue(e)}
     />
</View>

I want to send the value of "value" ("yes") to the getPollSelectionValue method. I have tried this:

getPollSelectionValue(e.target.value) 

But this did not work. How do I send the props value in the getPollSelectionValue method?

1 Answers

Use ToggleButton inside ToggleButton.Group

  const [value, setValue] = React.useState('');

  React.useEffect(() => {
    console.log('value :::' + value);
  }, [value]);

  return (
     <ToggleButton.Group
       onValueChange={(value) => setValue(value)}
       value={value}>
         <ToggleButton icon="check" value="yes" />
     </ToggleButton.Group>
  );
Related