To fix the "Property ‘value’ does not exist on type ‘Readonly<{}>’ " error with React TypeScript, we should specify the prop and state types in our React class component.
For instance, we write
type MyProps = {
//...
};
type MyState = { value: string };
class App extends React.Component<MyProps, MyState> {
//...
}
to specify the MyProps
and MyState
types as the types for the props and state of our React class component with
React.Component<MyProps, MyState>
We should add value
into the type specification since it’s specified in the error.