loading...

re: BuckleScript Belt’s Map and Set: customizing key types VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Question. How do you get the data into the ui from Belt.Map? [@react.component] let make = () => { // Belt.Map.toArray converts are Belt.Map...
 

It looks like the error is coming from this code: review->React.string. The review isn’t a string.

A few issues are related:

  1. Map.toArray returns an array of tuples like this: [|(key1, value1), (key2, value2)|]. If you just want an array of values, then use Map.valuesToArray to return [|value1, value2|].
  2. If you’re using my example code, then each value isn’t a review type, it’s a list of reviews (realistically, each book would have more than one review). You’d also have to turn that into an array and map it with a function that returns a React element.
  3. Since a review type isn’t a string, you’d have to pick which field you want to render, e.g.: review.text.

I hope that helps!

code of conduct - report abuse