File tree 3 files changed +10
-11
lines changed
packages/data/src/components
3 files changed +10
-11
lines changed Original file line number Diff line number Diff line change 3
3
*/
4
4
import { createContext } from '@wordpress/element' ;
5
5
6
- const { Consumer, Provider } = createContext ( null ) ;
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import defaultRegistry from '../../default-registry' ;
10
+
11
+ const { Consumer, Provider } = createContext ( defaultRegistry ) ;
7
12
8
13
export const RegistryConsumer = Consumer ;
9
14
Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ import {
17
17
/**
18
18
* Internal dependencies
19
19
*/
20
- import defaultRegistry from '../../default-registry' ;
21
20
import { RegistryConsumer } from '../registry-provider' ;
22
21
23
22
/**
@@ -50,15 +49,13 @@ const withDispatch = ( mapDispatchToProps ) => createHigherOrderComponent(
50
49
51
50
proxyDispatch ( propName , ...args ) {
52
51
// Original dispatcher is a pre-bound (dispatching) action creator.
53
- const dispatch = this . props . registry ? this . props . registry . dispatch : defaultRegistry . dispatch ;
54
- mapDispatchToProps ( dispatch , this . props . ownProps ) [ propName ] ( ...args ) ;
52
+ mapDispatchToProps ( this . props . registry . dispatch , this . props . ownProps ) [ propName ] ( ...args ) ;
55
53
}
56
54
57
55
setProxyProps ( props ) {
58
56
// Assign as instance property so that in reconciling subsequent
59
57
// renders, the assigned prop values are referentially equal.
60
- const dispatch = props . registry ? props . registry . dispatch : defaultRegistry . dispatch ;
61
- const propsToDispatchers = mapDispatchToProps ( dispatch , props . ownProps ) ;
58
+ const propsToDispatchers = mapDispatchToProps ( this . props . registry . dispatch , props . ownProps ) ;
62
59
this . proxyProps = mapValues ( propsToDispatchers , ( dispatcher , propName ) => {
63
60
// Prebind with prop name so we have reference to the original
64
61
// dispatcher to invoke. Track between re-renders to avoid
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import isShallowEqual from '@wordpress/is-shallow-equal';
11
11
/**
12
12
* Internal dependencies
13
13
*/
14
- import defaultRegistry from '../../default-registry' ;
15
14
import { RegistryConsumer } from '../registry-provider' ;
16
15
17
16
/**
@@ -40,9 +39,8 @@ const withSelect = ( mapStateToProps ) => createHigherOrderComponent( ( WrappedC
40
39
// A constant value is used as the fallback since it can be more
41
40
// efficiently shallow compared in case component is repeatedly
42
41
// rendered without its own merge props.
43
- const select = props . registry ? props . registry . select : defaultRegistry . select ;
44
42
const mergeProps = (
45
- mapStateToProps ( select , props . ownProps ) ||
43
+ mapStateToProps ( props . registry . select , props . ownProps ) ||
46
44
DEFAULT_MERGE_PROPS
47
45
) ;
48
46
@@ -66,8 +64,7 @@ const withSelect = ( mapStateToProps ) => createHigherOrderComponent( ( WrappedC
66
64
}
67
65
68
66
subscribe ( ) {
69
- const subscribe = this . props . registry ? this . props . registry . subscribe : defaultRegistry . subscribe ;
70
- this . unsubscribe = subscribe ( ( ) => {
67
+ this . unsubscribe = this . props . registry . subscribe ( ( ) => {
71
68
if ( ! this . canRunSelection ) {
72
69
return ;
73
70
}
You can’t perform that action at this time.
0 commit comments