Skip to content

Commit

Permalink
fix(Settings): save a new node from the hash
Browse files Browse the repository at this point in the history
  • Loading branch information
alexesDev committed Jul 31, 2023
1 parent 1ed1101 commit a0df553
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, FormEvent } from 'react';
import { useEffect, useState, FormEvent } from 'react';
import { useStore } from './store';
import * as s from './Settings.module.css';

Expand All @@ -10,6 +10,12 @@ export function Settings({ newNode }: Props) {
const { node, foldAmountObject, dispatch } = useStore('node', 'foldAmountObject');
const [currentNode, setCurrentNode] = useState(newNode || node);

useEffect(() => {
if (newNode) {
dispatch('setNode', newNode);
}
}, [node, newNode, dispatch]);

const saveNode = (e: FormEvent) => {
e.preventDefault();
dispatch('setNode', currentNode);
Expand Down

0 comments on commit a0df553

Please sign in to comment.