我习惯于在可能的情况下使用类组件
const mapStateToProps = (state) => {
return {
isMobile: isMobile(state)
}
}
并从此选择器中获取isMobile
的值
const width = state => state.ui.screenWidth
export const isMobile = createSelector(
width,
(screenWidth) => {
return screenWidth <= 810
}
)
使用useSelector时我无法获取值
const { isMobile } = useSelector(state => ({
isMobile: state.isMobile
}));
未定义
至
const { isMobile } = useSelector(state => ({
isMobile: isMobile(state)
}));
isMobile不起作用
我如何获得价值?谢谢