Merge pull request #7 from felixroos/main

fixed editor crash
This commit is contained in:
Alex McLean
2022-02-07 22:07:58 +00:00
committed by GitHub
2 changed files with 13 additions and 16 deletions
+6 -4
View File
@@ -43,9 +43,7 @@ function App() {
return [];
}
}, [pattern]),
onSchedule: useCallback((_events, cycle2) => {
logCycle(_events, cycle2);
}, [pattern]),
onSchedule: useCallback((_events, cycle2) => logCycle(_events, cycle2), [pattern]),
ready: !!pattern
});
useEffect(() => {
@@ -57,8 +55,12 @@ function App() {
} catch (err) {
setMode("javascript");
_pattern = parse(code);
if (_pattern?.constructor?.name !== "Pattern") {
const message = `got "${typeof _pattern}" instead of pattern`;
throw new Error(message + (typeof _pattern === "function" ? "did you foget to call a function?" : ""));
}
}
setPattern(_pattern);
setPattern(() => _pattern);
setError(void 0);
} catch (err) {
console.warn(err);