I am new to type script and I am trying to set the state in react using use state hook and type script.
const intialState: State ={
items: [],
value: "",
error: null
}
const [data, setData]= useState([intialState]);
return (
<>
{
data.items.map(x) => (
//my html component to be displayed.
)
}
</>
)
but I am getting the below error. Can any one tell me.
- Is it valid to set an object inside a usestate like I have done?
- Why I am getting the typescript error?