mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-27 15:22:56 +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 = () => {
|
export const JsonEditor: React.FC = () => {
|
||||||
const [json, setJson] = useLocalStorage("json", JSON.stringify(defaultValue));
|
const [json, setJson] = useLocalStorage("json", JSON.stringify(defaultValue));
|
||||||
|
const [initialJson, setInitialJson] = React.useState(json);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
setInitialJson(json);
|
||||||
|
}, []);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const element = document.querySelector(
|
const element = document.querySelector(
|
||||||
@ -71,7 +76,7 @@ export const JsonEditor: React.FC = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledJSONInput
|
<StyledJSONInput
|
||||||
placeholder={JSON.parse(json)}
|
placeholder={JSON.parse(initialJson)}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
locale={locale}
|
locale={locale}
|
||||||
height="100%"
|
height="100%"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user