aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lustre.ffi.mjs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/lustre.ffi.mjs b/src/lustre.ffi.mjs
index 4713750..b39db16 100644
--- a/src/lustre.ffi.mjs
+++ b/src/lustre.ffi.mjs
@@ -43,13 +43,16 @@ export const mount = (app, selector) => {
// bit of state to track whether we need to run the cmds we have or
// not.
const [shouldRunCmds, setShouldRunCmds] = React.useState(true);
- const [[state, cmds], dispatch] = React.useReducer((state, msg) => {
- // Every time we call the user's update function we'll get back a
- // new lot of cmds to run, so we need to set this flag to true to
- // let our `useEffect` know it can run them!
- setShouldRunCmds(true);
- return app.update(state, msg);
- }, app.init);
+ const [[state, cmds], dispatch] = React.useReducer(
+ ([state, _], msg) => {
+ // Every time we call the user's update function we'll get back a
+ // new lot of cmds to run, so we need to set this flag to true to
+ // let our `useEffect` know it can run them!
+ setShouldRunCmds(true);
+ return app.update(state, msg);
+ },
+ app.init
+ );
React.useImperativeHandle(ref, () => dispatch, [dispatch]);
React.useEffect(() => {