JavaScript for WordPress Forums Gutenberg Development Fragment vs. returning an array in edit

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #46231
    meszarosrob
    Participant

    I am watching the “04.07 – Example – Inspector Controls” episode and I can see that in the edit an array is returned and that array contains the InspectorControls, BlockControls, …

    Simultaneously I am checking out the core blocks. For example in /core-blocks/columns/index.js instead of an array a <Fragment> is returned which contains the IC, BC, … https://reactjs.org/docs/fragments.html

    I am new to React but from what I can figure this <Fragment> thing is pretty common (obviously based on my Google searches).

    Question: <Fragment> or array as in the 04.07 video?

    #46892
    Zac Gordon
    Keymaster

    This is a good question.

    In general I think using Fragments is a solid approach that is also quite common in React and some vanilla JS work.

    The ability to pass arrays here I like but it doesn’t always work best.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.