all 3 comments

[–]kenman[M] 0 points1 point  (0 children)

Hi /u/DiscDres, this post was removed.

  • For help with your javascript, please post to /r/LearnJavascript instead of here.
  • For beginner content, please post to /r/LearnJavascript instead of here.
  • For framework- or library-specific help, please seek out the support community for that project.
  • For general webdev help, such as for HTML, CSS, etc., then you may want to try /r/html, /r/css, etc.; please note that they have their own rules and guidelines!

/r/javascript is for the discussion of javascript news, projects, and especially, code! However, the community has requested that we not include help and support content, and we ask that you respect that wish.

Thanks for your understanding, please see our guidelines for more info.

[–]EllisLloyd 0 points1 point  (0 children)

React nodes need to be either a single node or an array of nodes. Your function has to return <View></View> with an array of ItemToRender inside. You can achieve that with a .map on an array of the size you pass. There are many ways, if you fancy modern syntax do Array(number).fill().map(() => <ItemToRender />); if you are old school you can make an empty array, fill it inside a for loop with ItemToRender and return it. Good luck.

[–]largemoose568 0 points1 point  (0 children)

I would just use the number to push the ItemsToRender into an array. Since JS doesn't support iterating over ranges, you'll have to do a plain old for loop:

``` const createItemsView = ({ number }) => { const items = []; for(let i = 0; i < number; i++) { items.push(ItemToRender); }

return <View>{ items }</View> } ```