react-redux-classconnect
Remove cognitive load by moving prop mapping into the component, by using static method references.
Quick Start
Instead of this:
static propTypes = friendList: PropTypesobjectisRequired actions: PropTypesobjectisRequired ; { const friendList: friendsById actions = thisprops; return <div className="friendListApp"> <h1>Da Bros List</h1> <AddFriendInput addFriend=actionsaddFriend /> <FriendList friends=friendsById actions=actions /> </div> ; } { return friendList: statefriendList ;} { return actions: ;} mapStateToProps mapDispatchToPropsFriendListApp;
Do this:
static propTypes = friendList: PropTypesobjectisRequired actions: PropTypesobjectisRequired ; static friendList: statefriendList static actions: { const friendList: friendsById actions = thisprops; return <div className="friendListApp"> <h1>Da Bros List</h1> <AddFriendInput addFriend=actionsaddFriend /> <FriendList friends=friendsById actions=actions /> </div> ; }FriendListApp;
Or, if your actions are pretty standard, just this:
static propTypes = friendList: PropTypesobjectisRequired actions: PropTypesobjectisRequired ; static friendList: statefriendList static actionProps = actions: FriendsActions { const friendList: friendsById actions = thisprops; return <div className="friendListApp"> <h1>Da Bros List</h1> <AddFriendInput addFriend=actionsaddFriend /> <FriendList friends=friendsById actions=actions /> </div> ; }FriendListApp;