This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2844 from korhaliv/chore/patch-redux-connect
chore: allow overriding state props in sb components
- Loading branch information
Showing
2 changed files
with
45 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
export { | ||
Provider, | ||
connectAdvanced, | ||
ReactReduxContext, | ||
batch, | ||
useDispatch, | ||
useSelector, | ||
useStore, | ||
shallowEqual, | ||
} from '../node_modules/react-redux' // full import path to avoid circular dep | ||
import { connect as originalConnect } from '../node_modules/react-redux' | ||
|
||
function defaultMergeProps(stateProps, dispatchProps, ownProps) { | ||
return { ...stateProps, ...dispatchProps, ...ownProps } | ||
} | ||
|
||
/** | ||
* connect - Patches redux connect function to use `defaultMergeProps` that prioritizes `ownProps` over `stateProps`. | ||
* | ||
* @param {*} mapStateToProps mapStateToProps | ||
* @param {*} mapDispatchToProps mapDispatchToProps | ||
* @param {*} [mergeProps=defaultMergeProps] mergeProps | ||
* @param {*} rest options | ||
* @returns {*} | ||
*/ | ||
export function connect( | ||
mapStateToProps, | ||
mapDispatchToProps, | ||
mergeProps = defaultMergeProps, | ||
...rest | ||
) { | ||
return originalConnect(mapStateToProps, mapDispatchToProps, mergeProps, ...rest) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters