Skip to content

Commit e052e31

Browse files
committed
Don't touch the API
1 parent 95a1432 commit e052e31

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/store.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function createStore(state, id = uuid()) {
3333
function createState(store, initialState) {
3434
const setState = changes => {
3535
store.state = { ...store.state, ...changes }
36-
store.subscriptions.forEach(callback => callback(store.state))
36+
store.subscriptions.forEach(callback => callback(changes))
3737
return true
3838
}
3939

@@ -95,24 +95,10 @@ export class Provider extends React.PureComponent {
9595
this.store.context = id ? createNamedContext(id) : ProviderContext
9696
}
9797

98-
let internalState = this.store.state
99-
10098
// When a store was given,
101-
// additional state is a different "initialState"
102-
if (store) {
103-
internalState = {
104-
...internalState,
105-
...state,
106-
// TODO: Should this try to update the store?
107-
// Changes to shadowed values in internal state won't propagate
108-
// to the external store
109-
...wrapStateUpdateFunctions(state, this, changes =>
110-
this.setState(changes)
111-
),
112-
}
113-
}
99+
// additional state could be different "initialState"
114100

115-
this.state = internalState
101+
this.state = this.store.state
116102
this.unsubscribe = this.store.subscribe(state => this.setState(state))
117103
}
118104

0 commit comments

Comments
 (0)