-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite connect2 to be a lot simpler #11
Conversation
a16e1e1
to
d70b50b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One gripe about comment clarity, but otherwise I'm good with this change
lib/connect2.lua
Outdated
self.mapStateToProps = mapStateToProps | ||
|
||
-- All of the values that we put into state are intended to be used | ||
-- by getDerivedStateFromProps, constructed using makeStateUpdater. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, the mappedStoreDispatch is only used in the stateUpdater itself, but both of those contexts have no knowledge of self
. Maybe could word this a little more clearly
lib/connect2.lua
Outdated
@@ -28,7 +28,7 @@ local function makeStateUpdater(store, mapStateToProps) | |||
-- The caller can optionally provide mappedStoreState if it needed that | |||
-- value beforehand. Doing so is purely an optimization. | |||
if mappedStoreState == nil then | |||
mappedStoreState = mapStateToProps(store:getState(), nextProps) | |||
mappedStoreState = prevState.mapStateToProps(store:getState(), nextProps) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to remove the mapStateToProps
argument to makeStateUpdater
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I think the detailed commenting is better.
Closes #9.
There are a number of prop/state synchronization bugs in the current
connect2
implementation, one of which is outlined in #9. I'm essentially rewriting most of the interesting logic from the ground up.I'm hoping to pattern some work based on reduxjs/react-redux#919 but while also trying to keep the complexity low. React-Redux's
connectAdvanced
function seems significantly more complicated than we need.