Ensure editor value updation on state change

This commit is contained in:
muzam1l
2022-07-18 21:26:05 +05:30
parent 168d11d48e
commit faa28845c8

View File

@@ -29,11 +29,18 @@ export const TxJson: FC<JsonProps> = ({
setState,
}) => {
const { editorSettings, accounts } = useSnapshot(state);
const { editorValue = getJsonString?.(), estimatedFee } = txState;
const { editorValue, estimatedFee } = txState;
const [currTxType, setCurrTxType] = useState<string | undefined>(
txState.selectedTransaction?.value
);
useEffect(() => {
setState({
editorValue: getJsonString?.(),
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => {
const parsed = parseJSON(editorValue);
if (!parsed) return;