mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-20 05:12:54 +08:00
remove unnecessary useEffect
This commit is contained in:
parent
208d42eb5b
commit
c093575700
@ -1,7 +1,6 @@
|
||||
import React from "react";
|
||||
import styled from "styled-components";
|
||||
import JSONInput from "react-json-editor-ajrm";
|
||||
import { useLocalStorage } from "usehooks-ts";
|
||||
import locale from "react-json-editor-ajrm/locale/en";
|
||||
|
||||
interface JsonData {
|
||||
@ -62,13 +61,7 @@ export const JsonEditor: React.FC<{
|
||||
React.useEffect(() => {
|
||||
const jsonStored = localStorage.getItem("json");
|
||||
if (jsonStored) setInitialJson(jsonStored);
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (json === "[]") setInitialJson(json);
|
||||
}, [json]);
|
||||
|
||||
React.useEffect(() => {
|
||||
const element = document.querySelector(
|
||||
'[name="outer-box"] > div'
|
||||
) as HTMLDivElement;
|
||||
@ -77,6 +70,10 @@ export const JsonEditor: React.FC<{
|
||||
}
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (json === "[]") setInitialJson(json);
|
||||
}, [json]);
|
||||
|
||||
const handleChange = (data: JsonData) => {
|
||||
if (!data.error) {
|
||||
if (data.json === "") return setJson("[]");
|
||||
@ -91,6 +88,11 @@ export const JsonEditor: React.FC<{
|
||||
locale={locale}
|
||||
height="100%"
|
||||
width="auto"
|
||||
style={{
|
||||
outerBox: {
|
||||
background: "blue",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user