From 89d222d96778a0a2369afefb51cbe5bdd99b7e9f Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Sun, 22 Mar 2020 23:24:12 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20R=C3=A9pare=20le=20publicode=20S?= =?UTF-8?q?tudio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TODO : ajouter un test d'intégration Cypress pour cette page --- source/sites/publi.codes/Studio.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 (