Skip to content
Snippets Groups Projects
Commit 36e46f49 authored by Maximilian Giller's avatar Maximilian Giller :squid:
Browse files

Fixed node types not updating when changing space

parent 94c27535
No related branches found
No related tags found
No related merge requests found
Pipeline #57044 passed
import React, { useState } from "react"; import React, { useEffect, useState } from "react";
import "./nodetypeseditor.css"; import "./nodetypeseditor.css";
import NodeTypeEntry from "./nodetypeentry"; import NodeTypeEntry from "./nodetypeentry";
import { NodeType, NodeTypeData } from "../../common/graph/nodetype"; import { NodeType, NodeTypeData } from "../../common/graph/nodetype";
...@@ -25,6 +25,10 @@ function NodeTypesEditor({ ...@@ -25,6 +25,10 @@ function NodeTypesEditor({
}: NodeTypesEditorProps) { }: NodeTypesEditorProps) {
const [selectedType, setSelectedType] = useState<NodeType>(nodeTypes[0]); // There should always exist at least one NodeType object const [selectedType, setSelectedType] = useState<NodeType>(nodeTypes[0]); // There should always exist at least one NodeType object
useEffect(() => {
setSelectedType(nodeTypes[0]);
}, [nodeTypes]);
const selectTypeWithId = (id: number) => const selectTypeWithId = (id: number) =>
setSelectedType(nodeTypes.find((type: NodeType) => type.id == id)); setSelectedType(nodeTypes.find((type: NodeType) => type.id == id));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment