I am learning React. I read an article that suggests us to use functional component instead of class that extends React.Component, so I followed. I also use the arrow function instead of function keyword. That is:
const MyComponent = (props) => {...}
I got a structure that has 20 properties like:
{
id: '',
firstname: '',
lastname: '',
...
}
I am using if ... else if ... to set the state, but I saw some examples that use this.setState() in just one line of code. I try to import setState from 'react', but fail.
Is there a way to use setState() instead of setName(), setId(), ..., etc? Or any suggestion?
Thank you very much!