) => T,
+ equality?: (a: T, b: T) => boolean
+) {
+ return useStoreWithEqualityFn(useSharedStore.temporal, selector!, equality);
+}
+
+const UndoBar = () => {
+ const { undo, redo, pastStates, futureStates } = useTemporalStore(
+ (state) => ({
+ undo: state.undo,
+ redo: state.redo,
+ pastStates: state.pastStates,
+ futureStates: state.futureStates,
+ })
+ );
+
+ return (
+
+ past states: {JSON.stringify(pastStates)}
+
+ future states: {JSON.stringify(futureStates)}
+
+
+
+
+ );
+};
+
+const BearState = () => {
+ const { bears, addBear, eatFish } = useSharedStore(useShallow((state) => ({
+ bears: state.bears,
+ addBear: state.addBear,
+ eatFish: state.eatFish,
+ })));
+
+ return (
+
+ bears: {bears}
+
+
+
+
+ );
+};
+
+const FishState = () => {
+ const { fishes, addFish } = useSharedStore(useShallow((state) => ({
+ fishes: state.fishes,
+ addFish: state.addFish,
+ })));
+
+ return (
+
+ fishes: {fishes}
+
+
+
+ );
+};
+
+const App = () => {
+ return (
+
+
+ {' '}
+
+ 🐻
+ {' '}
+
+ ♻️
+ {' '}
+ Zundo!
+
+
+
+
+
+
+ );
+};
+
+export default App;