【发布时间】:2022-01-06 14:28:27
【问题描述】:
在这里找到我的代码,当我尝试获取名字时,我遇到了“无法读取未定义的属性”的问题,有人可以提供解决方案或解释我的代码有什么问题
let state = useSelector(state => {
// console.log('State: ', state.profile);
return state.profile;
});
const [profile, setProfile] = useState();
const [formState, setFormState] = useState({
isValid: false,
values: {},
touched: {},
errors: {}
});
useEffect(()=>{
console.log({accesstoken: token});
if(token)
dispatch(profileActions.getInfos({accesstoken: token}));
},[])
useEffect(()=>{
if (state)
setProfile(state)
console.log(profile.profile);
},[state, profile])
/// here the peace of code to display the profile.data.firstname
ListItemText primary="Date de creation" secondary{JSON.stringify(profile.data.firstName)} />
【问题讨论】:
标签: node.js reactjs redux use-state