Consider this function for example:
onChange = (event, { newValue }) => {
this.setState({
value: newValue,
});
};
What is the difference between { newValue }
and just using newValue
.
Example taken from here.
Is i'm using typescript, is using
onChange = (event, { newValue }: string) => {
this.setState({
value: newValue,
});
};
any different from
onChange = (event, newValue: string) => {
this.setState({
value: newValue,
});
};
Thank you for helping me understand!
If as a second argument would be passed an object with keys eg.:
{value:'aaa', newValue: 'bbb', anotherValue: 'ccc'}
the second argument will take object property newValue
as a value
In other words you can pass whole object as second argument but ONLY its newValue
property will be used as a value of second argument