Writing a custom hook that syncs your internal state with props in React and TypeScript.
Let's say, for whatever reason, you ran into a scenario where you wanted to create an internal state that can be overwritten when a prop changes.
You might write it like this.
type SearchBoxProps = {
// the prop we want to derive
query: string
}
...
imekachi.hashnode.dev8 min read