Skip to content

Instantly share code, notes, and snippets.

@marshallmurphy
Created May 8, 2020 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marshallmurphy/72b98cf091b89c8fd33418bacfdad47c to your computer and use it in GitHub Desktop.
Save marshallmurphy/72b98cf091b89c8fd33418bacfdad47c to your computer and use it in GitHub Desktop.
// screens/Settings.js
const Section = ({ option, active, pos, index }) => {
const dispatch = useDispatch();
let settings = useSelector(state => state.settings);
function update(pos, index) {
settings[index].active = pos;
dispatch(updateSettings(settings));
}
return (
<View style={styles.section}>
<Text style={styles.sectionTitle}>{option}</Text>
{active === pos ? (
<TouchableOpacity style={styles.radioFill}>
<View style={styles.radioFillCenter}></View>
</TouchableOpacity>
) : (
<TouchableOpacity style={styles.radio} onPress={() => update(pos, index) } />
)}
</View>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment