Skip to content

Commit 10f69a1

Browse files
committed
fix: remove optional chaining syntax
1 parent 5298888 commit 10f69a1

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

client-src/overlay/fsm.js

+17-10
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,26 @@ function createMachine({ states, context, initial }, { actions }) {
3636

3737
return {
3838
send: (event) => {
39-
const transitionConfig = states[currentState].on?.[event.type];
39+
const currentStateOn = states[currentState].on;
40+
const transitionConfig = currentStateOn && currentStateOn[event.type];
4041

4142
if (transitionConfig) {
4243
currentState = transitionConfig.target;
43-
transitionConfig.actions?.forEach((actName) => {
44-
const nextContextValue = actions[actName]?.(currentContext, event);
45-
if (nextContextValue) {
46-
currentContext = {
47-
...currentContext,
48-
...nextContextValue,
49-
};
50-
}
51-
});
44+
if (transitionConfig.actions) {
45+
transitionConfig.actions.forEach((actName) => {
46+
const actionImpl = actions[actName];
47+
48+
const nextContextValue =
49+
actionImpl && actionImpl(currentContext, event);
50+
51+
if (nextContextValue) {
52+
currentContext = {
53+
...currentContext,
54+
...nextContextValue,
55+
};
56+
}
57+
});
58+
}
5259
}
5360
},
5461
};

0 commit comments

Comments
 (0)