diff --git a/source/sites/publi.codes/Studio.tsx b/source/sites/publi.codes/Studio.tsx index a0fd76111..bde859a40 100644 --- a/source/sites/publi.codes/Studio.tsx +++ b/source/sites/publi.codes/Studio.tsx @@ -3,7 +3,7 @@ import douche from '!!raw-loader!./exemples/douche.yaml' import { ControlledEditor } from '@monaco-editor/react' import Engine from 'Engine/react' import { safeLoad } from 'js-yaml' -import React, { useState } from 'react' +import React, { useEffect, useState } from 'react' import emoji from 'react-easy-emoji' import { useLocation } from 'react-router' import styled from 'styled-components' @@ -38,9 +38,11 @@ export default function Studio() { const [targets, setTargets] = useState([]) const [rules, setRules] = useState(editorValue) - try { - setTargets(Object.keys(safeLoad(editorValue) ?? {})) - } catch {} + useEffect(() => { + try { + setTargets(Object.keys(safeLoad(editorValue) ?? {})) + } catch {} + }, [editorValue]) return (