const [value, set_value] = useState({a: 1});
<Child
value={value}
onChange={callback}
</Child>
set_value({a: 2})
When set_value({a: 2}) is run, will that trigger the callback inside of the onChange to run?
I think the most exact answer to the question is:
"That is up to the <Child> component."
From Reacts point of view value and onChange are just two properties of <Child>, so:
No, changing one property (value) doesn't necessarily cause any callbacks (onChange) to be called.
But it is common in React to have so called "controlled-components", where the state (i.e. the value) is kept inside the parent, and the child doesn't have any own state, but will receive the value from the parent, and only informs the parent about changes.
In your example the parent component keeps the state:
const [value, set_value] = useState({a: 1});
And the child might only receive the value and call the callback if changes are necessary (but doesn't keep any own state), e.g.:
const Child = function( props ){
return <button onClick={ function(){
props.onChange( props.value.a + 1 );
}}>
{ props.value.a }
</button>
};