Skip to content

I need to create a component that will render multiple node containers inside. How can I do that? #53

Discussion options

You must be logged in to vote

If you need four containers that you want to display in different parts of the component, you can describe four properties. I think the example will make it clear:

import {define, node, nodeArray, useBuilderContext} from '@react-form-builder/core'
import type {ReactNode} from 'react'

interface FourProps {
  one?: ReactNode
  two?: ReactNode[]
  three?: ReactNode
  four?: ReactNode
}

const Four = (props: FourProps) => {
  const context = useBuilderContext()

  // You can show different components in builder and view modes
  const two = context.builderMode === 'builder'
    ? props.two
    : props.two && props.two.length && props.two[0]

  return <div>
    <div>
      <h1>One</h1>
      {p…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@tuthanhoancanh012
Comment options

@optimajet
Comment options

@tuthanhoancanh012
Comment options

@optimajet
Comment options

@tuthanhoancanh012
Comment options

Answer selected by sergeythrees
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants