setting usestate to prop code example
Example: setting usestate to prop
function Avatar(props) {
const [user, setUser] = React.useState({...props.user});
React.useEffect(() => {
setUser(props.user);
}, [props.user])
return user.avatar ?
()
: (Loading...
);
}