static getDerivedStateFromProps(props) {
const {
name
} = props.users;
return { name };
}
}
With the above code, I got an error of
TypeError
Cannot read property 'name' of undefined
What is the issue? I thought object deconstructing will handle automatically if users
is undefined?
Can I use if statement in getDerivedStateFromProps
and without return anything?