Skip to content

Fix example in Rescript-React docs Arrays and Keys > Rendering list Values #454

Closed
@zprayz

Description

@zprayz

The current example is incorrect. In the let items binding it is taking a list and converting it to an array and then trying to pipe it to a function that takes a list.

type todo = {id: string, text: string}
let todoList = list{
  {id: "todo1", text: "Todo 1"},
  {id: "todo2", text: "Todo 2"}
}

let items =
  todoList
  ->Belt.List.toArray
  ->Belt.List.map((todo) => {  //  <-------  I believe this should be Belt.Array.map and not Belt.List.map
  <li key={todo.id}>
    {React.string(todo.text)}
  </li>
})

<div> {React.array(items)} </div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions