I'm trying to toggle a radio button and update a prop to what current value it's set on.
My Modal
component is rendering a RadioButton
component as so:
<RadioButton
currentValue={destination}
name={text.newOpp}
onChange={onClick}
value={text.newOpp}
labelText={text.newOpp}
/>
The onClick
function is being passed in and looks like this at the moment:
export const onClick = ({ destination }) => ({ target }) => {
let copyDestination = {};
copyDestination.destination = target.name;
destination = copyDestination;
// this doesn't really do anything
};
export default compose(
...
...
withProps({ destination: '' }),
...
);
RadioButton
is enhanced with recompose
and passed this function in as a prop:
export const checked = ({ currentValue, value }) => {
return currentValue === value;
};
And this is what the input section of the component looks like:
<input
checked={checked}
className={styles.input}
id={uniqueIdForHTML}
name={name}
onChange={onChange}
type="radio"
value={value}
/>
Essentially, the way this should work is that when I click on a radio button, I update its currentValue
prop to whatever target.name
is equal to. But I'm not entirely sure how to update the prop since they should not be altered directly.