Build a component that works controlled and uncontrolled with the same code.
This is custom React hooks, you need to follow the Basic Rules when you use it.
The same component keeps its own state or follows the value prop.
const useUncontrolled = <T>(options: {
value?: T
defaultValue?: T
finalValue?: T
onChange?: (value: T) => void
}) => [T, (value: T) => void, boolean]