import { createSelector } from 'reselect'
export const selectUser = createSelector(
[state => state.user],
user => user
)
const { user } = useSelector(state => selectUser(state))
我试图防止在我的react应用程序中进行不必要的重新渲染。我想使用reselect
冻结我的user
对象。但当我以异步方式从后端加载页面用户对象时,reselect
将该值冻结为undefined
。当user
对象来自back-end
并保存到我的redux
存储时,我如何防止它并冻结它?
用户是undefined
,因为我没有正确检索到它
const user = useSelector(state => selectUser(state))