mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-20 05:12:54 +08:00
fix rerender on save json
This commit is contained in:
parent
1d5e58c18d
commit
4c80f6f30a
@ -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%"
|
||||
|
Loading…
x
Reference in New Issue
Block a user