I'm trying to make a generic Input component with a clear button but I'm having trouble with clearing the state from within the component itself when the parent is holding the state.
Setting the ref value to '' doesn't trigger the onChange event.
Don't know how to call props.onChange in the Input component since I'm using typescript in my project and onChange expects event type.
Here is a recreation of my problem https://codesandbox.io/s/vigilant-voice-rwy2ms?file=/src/App.js
Type something in the input field. Press Clear. The input field sets to empty but the state in parent is not reset.
update Some answers are recommending a clearCallbackFunction or sendind setText down to the child. The input component will be part of a component library so I don't want the parent to care about the clear function and ut would be nice to not add props to the input field.