From a4f38b58cea74866e9c3e2d57587d903ebd2344b Mon Sep 17 00:00:00 2001 From: Marc Agbanchenou Date: Wed, 17 Feb 2021 00:09:54 +0100 Subject: [PATCH] [docs/react] Fix keys and arrays example * Use correctly `Belt.Array.mapWithIndex` * Convert index to string * Highlight first line (as a newcommer to rescript you're likely to ignore that you need a different function to access index within a map call). --- pages/docs/react/latest/arrays-and-keys.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/docs/react/latest/arrays-and-keys.mdx b/pages/docs/react/latest/arrays-and-keys.mdx index c3e11939e..f3bc310a2 100644 --- a/pages/docs/react/latest/arrays-and-keys.mdx +++ b/pages/docs/react/latest/arrays-and-keys.mdx @@ -41,10 +41,10 @@ let items = Belt.Array.map(todos, todo => { If you don’t have stable IDs for rendered items, you may use the item index as a key as a last resort: -```res {2,3} -let items = Belt.Array.mapWithIndex(todos, (todo, i) => { +```res {1..3} +let items = Belt.Array.mapWithIndex(todos, (i, todo) => { // Only do this if items have no stable id -
  • +
  • {todo.text}
  • });