考虑这个
componentDidMount() {
const { currentUserId, userList } = this.props;
//I get these from redux' mapStateToProps function;
//these are not passed down as regular props.
Mousetrap.bind(['shift+right'], () =>
nextUser(currentUserId, userList)
);
}
假设我的列表中有 10 个用户,我们从user 1
. 当我启动应用程序时,它会从user 1
到user 2
; 但是,它不会再进一步,因为 的值currentUserId
将永远是user 1
。
我怎样才能规避这一点并使论点是动态的,以便更新论点?
编辑:currentUserId
&userList
通过 Redux 传递给组件