🐛 Répare le publicode Studio

TODO : ajouter un test d'intégration Cypress pour cette page
pull/933/head
Maxime Quandalle 2020-03-22 23:24:12 +01:00
parent 57bb595884
commit 89d222d967
No known key found for this signature in database
GPG Key ID: 428641C03D29CA10
1 changed files with 6 additions and 4 deletions

View File

@ -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<string[]>([])
const [rules, setRules] = useState(editorValue)
try {
setTargets(Object.keys(safeLoad(editorValue) ?? {}))
} catch {}
useEffect(() => {
try {
setTargets(Object.keys(safeLoad(editorValue) ?? {}))
} catch {}
}, [editorValue])
return (
<Engine.Provider rules={rules}>