Skip to content

Commit

Permalink
Fixed circular dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkmcc committed Jan 16, 2024
1 parent 69edee8 commit 46dfb0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { CSSProperties, JSXElementConstructor } from 'react'
import { buildNode } from './node-types'
import {
BaseInputProps,
getBuiltinInputs,
Expand Down Expand Up @@ -335,7 +334,9 @@ export class GraphConfig {
}
}

getNodeComponents(): Record<string, JSXElementConstructor<any>> {
getNodeComponents(
buildNode: (node: NodeConfig) => JSXElementConstructor<any>,
): Record<string, JSXElementConstructor<any>> {
return Object.entries(this.nodes)
.map(([type, node]): [string, JSXElementConstructor<any>] => {
if (node.custom) {
Expand Down
3 changes: 2 additions & 1 deletion lib/hooks/config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { JSXElementConstructor, useMemo } from 'react'
import { useGraphConfig } from '../context/GraphConfigContext'
import { GraphConfig, IGraphConfig } from '../config.ts'
import { buildNode } from '../node-types.tsx'

export function useNodeTypes(): Record<string, JSXElementConstructor<any>> {
const [config] = useGraphConfig()
return useMemo(() => config.getNodeComponents(), [config])
return useMemo(() => config.getNodeComponents(buildNode), [config])
}

export function useBuildGraphConfig(
Expand Down

0 comments on commit 46dfb0d

Please sign in to comment.