fix rerender on save json

This commit is contained in:
Aykut Saraç 2022-02-06 18:28:25 +03:00
parent 1d5e58c18d
commit 4c80f6f30a

View File

@ -55,6 +55,11 @@ export const defaultValue = [
export const JsonEditor: React.FC = () => {
const [json, setJson] = useLocalStorage("json", JSON.stringify(defaultValue));
const [initialJson, setInitialJson] = React.useState(json);
React.useEffect(() => {
setInitialJson(json);
}, []);
React.useEffect(() => {
const element = document.querySelector(
@ -71,7 +76,7 @@ export const JsonEditor: React.FC = () => {
return (
<StyledJSONInput
placeholder={JSON.parse(json)}
placeholder={JSON.parse(initialJson)}
onChange={handleChange}
locale={locale}
height="100%"