Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.3k
Rewrite connect() for better performance and extensibility#416
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
ee4366b2aec436fe7358c9967a18a12c1ec27f613d106ded6cde8ba25a631ab3416b4267868245e72f237890b4c612562d81434df71655ad3266aa94dbeeb174e0e09cd75a229de43b23e1ddbdb76920970395c92ae0c3ce2e710888e768bd2b9844859d795ce49933c72bcc09fef522ed52f0539fbe001b8fb695f0f85f03c62ef0906904d4686d8a45ae23e51315f4969368b1cc3d378045dc846c09bee77f3f8170f1632875460b9fd9530857f41e0a66c5bc7b831e7f2d7e284d8b395c4eedab9c85cabd37635d175f67d6e13a604856652d85cd56c36d418b65944fd92d1cb72c05ec8143112055555b49b286a4bbe3cc504f3c5c80ede81801e2df051e907f85a6d82f0a4d3211File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -34,20 +34,20 @@ export function dispatchable(actionCreator, ...selectorsToPartiallyApply) { | ||
| let hotReloadingVersion = 0 | ||
| export default functionconnectAdvanced( | ||
| /* | ||
| selectorFactory is afunc is responsible for returning the selector function used to compute new | ||
| props fromstate, props, and dispatch. For example: | ||
| export defaultconnectAdvanced(() => (state, props, dispatch) => ({ | ||
| thing: state.things[props.thingId], | ||
| saveThing: fields => dispatch(actionCreators.saveThing(props.thingId, fields)), | ||
| }))(YourComponent) | ||
| Alternatively, it can return a plain object which will be passed to reselect's | ||
| 'createStructuredSelector' function to create the selector. For example: | ||
| returnconnectAdvanced(() => ({ | ||
| thing: (state, props) => state.things[props.thingId], | ||
| saveThing: (_, props, dispatch) => fields => ( | ||
| dispatch(actionCreators.saveThing(props.thingId, fields)) | ||
| @@ -57,9 +57,9 @@ export default function connectToStore( | ||
| This is equivalent to wrapping the returned object in a call to `createStructuredSelector`, | ||
| but is supported as a convenience; This is the recommended approach to defining your | ||
| selectorFactory methods. The above example can be simplfied by using the `dispatchable` helper | ||
| method provided withconnectAdvanced: | ||
| connectAdvanced(() => ({ | ||
| thing: (state, props) => state.things[props.thingId], | ||
| saveThing: dispatchable(actionCreators.saveThing, (_, props) => props.thingId), | ||
| }))(YourComponent) | ||
| @@ -73,10 +73,10 @@ export default function connectToStore( | ||
| // options object: | ||
| { | ||
| // the func used to compute this HOC's displayName from the wrapped component's displayName. | ||
| getDisplayName = name => `connectAdvanced(${name})`, | ||
| // shown in error messages | ||
| methodName = 'connectAdvanced', | ||
| // if true, shouldComponentUpdate will only be true of the selector recomputes for nextProps. | ||
| ||
| // if false, shouldComponentUpdate will always be true. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import Provider from './components/Provider' | ||
| import connect from './components/connect' | ||
| importconnectAdvanced, { dispatchable } from './components/connectAdvanced' | ||
| export { Provider, connect,connectAdvanced, dispatchable } |