Skip to content

Commit

Permalink
Add useEffect hook to initialize math node properties
Browse files Browse the repository at this point in the history
  • Loading branch information
tfukaza committed Jul 7, 2024
1 parent f2c9817 commit 1cc71f3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion demo/react/src/components/Math.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import React from "react";
import { useState } from "react";
import { useEffect } from "react";
import Node from "./lib/Node";
import Output from "./lib/Output";
import InputNumber from "./lib/InputNumber";

export default function MathNode(nodeObject) {
let [node, setNode] = useState(nodeObject);

node.prop.operation = "+";
useEffect(() => {
node.prop.operation = "+";
node.prop.input_1 = 0;
node.prop.input_2 = 0;
node.prop.result = 0;
}, []);

function calculateMath() {
let input1 = +node.prop.input_1;
Expand Down

0 comments on commit 1cc71f3

Please sign in to comment.