Skip to content

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

editor fix clear issue

Aykut Saraç692690e68b37
diff --git a/src/containers/JsonEditor/index.tsx b/src/containers/JsonEditor/index.tsx
index b7d6e299..e942b2b9 100644
--- a/src/containers/JsonEditor/index.tsx
+++ b/src/containers/JsonEditor/index.tsx
@@ -56,7 +56,7 @@ export const defaultValue = [
export const JsonEditor: React.FC = () => {
const [clear, setClear] = React.useState(0);
const [json, setJson] = useLocalStorage("json", JSON.stringify(defaultValue));
- const initialJson = React.useMemo(() => JSON.parse(json), []);
+ const initialJson = React.useMemo(() => JSON.parse(json), [clear]);
React.useEffect(() => {
if (json === "[]") setClear((c) => c + 1);
@@ -69,7 +69,7 @@ export const JsonEditor: React.FC = () => {
if (element) {
element.style.transform = "translate(-75%, 25%)";
}
- }, [json]);
+ }, []);
const handleChange = (data: JsonData) => {
if (!data.error) {
@@ -85,7 +85,6 @@ export const JsonEditor: React.FC = () => {
locale={locale}
height="100%"
width="auto"
- key={clear}
/>
);
};