Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: block of list type returning children as string instead of array #36

Closed
pappitito opened this issue May 8, 2024 · 1 comment
Closed
Labels
issue: bug Issue reporting a bug

Comments

@pappitito
Copy link

What version of @strapi/blocks-react-renderer are you using?

-npm: 9.8.1 - node 18.18.0 - "@strapi/blocks-react-renderer": "^1.0.1"

What's Wrong?

given i want to customize a block with type list and i add the return function with destructured parameter being "children" and "format". i am unable to return a node where the children are being mapped, says i cannot map children of type string.

To Reproduce

<BlocksRenderer
content={content}
blocks={{
list : ({format, children, })=>{
if(format === 'ordered'){
//line below returns error saying i cannot map children because it is of type string
return

{ children.map((item, index)=>(
  • {item}
  • ))
    }

    }
    }
    }}
    />

    Expected Behaviour

    i should be able to map children

    @pappitito pappitito added the issue: bug Issue reporting a bug label May 8, 2024
    @remidej
    Copy link
    Contributor

    remidej commented May 21, 2024

    Hello, I don't think this is a bug. list blocks aren't meant to have access to the list items directly, they should just render the shell of the shell of the list. The content is then displayed by the list-item blocks.

    You can see what it looks like with the default components:

    {
      list: (props) => {
        if (props.format === 'ordered') {
          return <ol>{props.children}</ol>;
        }
    
        return <ul>{props.children}</ul>;
      },
      'list-item': (props) => <li>{props.children}</li>,
    }

    @remidej remidej closed this as completed May 21, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    issue: bug Issue reporting a bug
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants