prevwong / craft.js

🚀 A React Framework for building extensible drag and drop page editors
https://craft.js.org
MIT License
7.58k stars 738 forks source link

renderLayer not rendering all layers #547

Open rhit-kennymm opened 1 year ago

rhit-kennymm commented 1 year ago

Describe the bug on calling renderLayer in the Layers component, only the root container shows up all the other layers just disappear. Also is there more documentation on how you can style the individual layers

ylnsnv commented 1 month ago

I'm also struggling with this part myself, but regarding your issue with other layers disappearing, it likely has to do with the children prop being ignored in your custom layer rendering.

To ensure that all layers are rendered correctly, you should include the children prop when defining your custom rendering logic. Here's an example:

<Layers
  expandRootOnLoad={true}
  renderLayer={({ id, ...props }) => {
    return (
      <DefaultLayer id={id} {...props}>
        <CustomLayerHeader /> {/* Custom layer header with your icons */}
        {props.children} {/* Ensure you render children to display nested layers */}
      </DefaultLayer>
    );
  }}
/>