Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function identityFn(n) {

export default function createCopyOnWriteState(baseState) {
let updateState = null;
let currentState = baseState;
const State = createContext(baseState);
// Wraps immer's produce. Only notifies the Provider
// if the returned draft has been changed.
Expand Down Expand Up @@ -72,6 +73,7 @@ export default function createCopyOnWriteState(baseState) {
if (nextState === state) {
return null;
}
currentState = nextState;
return nextState;
});
};
Expand Down Expand Up @@ -148,6 +150,7 @@ export default function createCopyOnWriteState(baseState) {
Provider: CopyOnWriteStoreProvider,
Consumer: CopyOnWriteConsumer,
mutate,
createSelector
createSelector,
getCurrent: () => currentState
};
}