Answer the question
In order to leave comments, you need to log in
TS React children state?
There is such a beautiful error, TS does not allow me to dynamically shove data into the state. That is, I need to pass data from parent to child, and pass the function that is provided below. Which component would use. To pass the data back. Data is a lot of state big. How to deal with TS in this case?
PS. "noImplicitAny": false flag enabled
public ChildrenSetState = (name:any,value:any) => {
this.setState({[name]:value})
}
[Ошибка]: Argument of type '{ [x: number]: any; }' is not assignable to parameter of type 'State
Answer the question
In order to leave comments, you need to log in
// @ts-ignore
Set at the beginning of the file, but it's ridiculous.
Or it is normal to type this function (why do you need ts at all if you write any?), or plug the type field into the state type[k: any]: any
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question