2

I have two props in my Component: nodeTypes prop which is of NodeType[] type (list of node types) and second prop Nodes which are the React components that should corresponds to node types from nodeTypes prop (so it should be an object whose keys are NodeTypes from nodeTypes prop). How how can set it up?

1 Answer 1

1

To infer the type of the nodeTypes prop, which is an array, for the Nodes prop, which should represent an item from the nodeTypes array, you can use the following type for the Nodes prop:

Nodes: { [key in NodeType]: React.ComponentType<any> }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.