Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

fix rerender on save json

Aykut Saraç4c80f6f30a40
diff --git a/src/containers/JsonEditor/index.tsx b/src/containers/JsonEditor/index.tsx
index 7a75925f..5135726f 100644
--- a/src/containers/JsonEditor/index.tsx
+++ b/src/containers/JsonEditor/index.tsx
@@ -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%"