Avatar ·

Error "Property 'value' does not exist on type 'Readonly<{}>'" in React and TypeScript

Hi everyone! I'm a beginner in TypeScript and React, and I've been struggling with this error for several hours. \n\nI have a simple component that should get a value from an input and display it. Here's my code:\n\n```typescript\nimport React, { useState } from 'react';\n\nfunction MyComponent() {\n const [state, setState] = useState({});\n\n const handleChange = (e: React.ChangeEvent) => {\n setState({ value: e.target.value });\n };\n\n return (\n
\n \n

Value: {state.value}

\n
\n );\n}\n```\n\nWhen trying to access `state.value`, TypeScript throws an error: \n**"Property 'value' does not exist on type 'Readonly<{}>'"**\n\nI understand that TypeScript is saying that the object `{}` doesn't have a `value` property. But I'm