From faa28845c8c728ab7f1ace22c8350c6c8d0b6cdd Mon Sep 17 00:00:00 2001 From: muzam1l Date: Mon, 18 Jul 2022 21:26:05 +0530 Subject: [PATCH] Ensure editor value updation on state change --- components/Transaction/json.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/Transaction/json.tsx b/components/Transaction/json.tsx index fed2826..e37a286 100644 --- a/components/Transaction/json.tsx +++ b/components/Transaction/json.tsx @@ -29,11 +29,18 @@ export const TxJson: FC = ({ setState, }) => { const { editorSettings, accounts } = useSnapshot(state); - const { editorValue = getJsonString?.(), estimatedFee } = txState; + const { editorValue, estimatedFee } = txState; const [currTxType, setCurrTxType] = useState( txState.selectedTransaction?.value ); + useEffect(() => { + setState({ + editorValue: getJsonString?.(), + }); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + useEffect(() => { const parsed = parseJSON(editorValue); if (!parsed) return;