Unable to loop and render FlatList inside .map function react-nativeJavaScript closure inside loops – simple practical exampleLoop inside React JSXWhat is the difference between using constructor vs getInitialState in React / React Native?What is the difference between React Native and React?React Native ScrollView/FlatList not scrollingReact Native FlatList horizontal paging TouchableOpacity scrollToIndex infinite loopElements inside ScrollView dont scroll React nativeReact-Native FlatList doest not scroll on AndroidNot able to navigate to other page in react nativeReact-Native Flatlist not rendering when record is single

Is there a name for the trope when there is a moments dialogue when someone pauses just before they leave the room?

Do I have to explain the mechanical superiority of the player-character within the fiction of the game?

Boss wants someone else to lead a project based on the idea I presented to him

What is the most suitable position for a bishop here?

Resistance between non-inverting input of op-amp and voltage source

Is the specular reflection on a polished gold sphere white or gold in colour?

What is the oldest commercial MS-DOS program that can run on modern versions of Windows without third-party software?

Is the continuity test limit resistance of a multimeter standard?

Greeting with "Ho"

Subtract the Folded Matrix

Are there any individual aliens that have gained superpowers in the Marvel universe?

Cut the gold chain

Why don't we have a weaning party like Avraham did?

Why does Linux list NVMe drives as /dev/nvme0 instead of /dev/sda?

What was the first third-party commercial application for MS-DOS?

Improve appearance of the table in Latex

How did the Vostok ejection seat safely eject an astronaut from a sealed space capsule?

What mathematical theory is required for high frequency trading?

Why is it easier to balance a non-moving bike standing up than sitting down?

Syntax and semantics of XDV commands (XeTeX)

How does DC work with natural 20?

Find the common ancestor between two nodes of a tree

What is the "ls" directory in my home directory?

How can I ping multiple IP addresses at the same time?



Unable to loop and render FlatList inside .map function react-native


JavaScript closure inside loops – simple practical exampleLoop inside React JSXWhat is the difference between using constructor vs getInitialState in React / React Native?What is the difference between React Native and React?React Native ScrollView/FlatList not scrollingReact Native FlatList horizontal paging TouchableOpacity scrollToIndex infinite loopElements inside ScrollView dont scroll React nativeReact-Native FlatList doest not scroll on AndroidNot able to navigate to other page in react nativeReact-Native Flatlist not rendering when record is single






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I am trying to render a FlatList inside a component. The Component itself is inside a ScrollView.



I am using map function to loop through the data to pass into the component.
Earlier I was using ScrollView instead of FlatList. It was working fine, but was rendering slow. So I decided to use FlatList.



Here's my code:



 renderComp()

const filtersView,cats,cats_title, clearStyle = styles;

const data = this.props.ingreds;

const arr = Object.entries(data);


return arr.map(i=>
const name= i[0];
const items_obj = i[1];
const items = Object.values(items_obj);

return(

<View key=name style= filtersView>

<View style=cats>

<Text style =cats_title>name</Text>

<Text style=clearStyle>Clear All</Text>
</View>


<View style=justifyContent:'flex-start', alignItems:'flex-start'>

<FlatList
style= marginRight:6
data=items
keyExtractor=(x,i)=> i.toString()
renderItem=(item) =>
this.renderItems(item)

/>
</View>
</View>

)
)




And here's the ScrollView Component:



 <ScrollView contentContainerStyle=alignItems:'flex-start', 
justifyContent:'flex-start',flex:1, height:72 >

this.renderComp()

</ScrollView>


And The loop stops after one iteration.



Here's the output: https://i.stack.imgur.com/yM151.png



Any suggestions?










share|improve this question




























    1















    I am trying to render a FlatList inside a component. The Component itself is inside a ScrollView.



    I am using map function to loop through the data to pass into the component.
    Earlier I was using ScrollView instead of FlatList. It was working fine, but was rendering slow. So I decided to use FlatList.



    Here's my code:



     renderComp()

    const filtersView,cats,cats_title, clearStyle = styles;

    const data = this.props.ingreds;

    const arr = Object.entries(data);


    return arr.map(i=>
    const name= i[0];
    const items_obj = i[1];
    const items = Object.values(items_obj);

    return(

    <View key=name style= filtersView>

    <View style=cats>

    <Text style =cats_title>name</Text>

    <Text style=clearStyle>Clear All</Text>
    </View>


    <View style=justifyContent:'flex-start', alignItems:'flex-start'>

    <FlatList
    style= marginRight:6
    data=items
    keyExtractor=(x,i)=> i.toString()
    renderItem=(item) =>
    this.renderItems(item)

    />
    </View>
    </View>

    )
    )




    And here's the ScrollView Component:



     <ScrollView contentContainerStyle=alignItems:'flex-start', 
    justifyContent:'flex-start',flex:1, height:72 >

    this.renderComp()

    </ScrollView>


    And The loop stops after one iteration.



    Here's the output: https://i.stack.imgur.com/yM151.png



    Any suggestions?










    share|improve this question
























      1












      1








      1








      I am trying to render a FlatList inside a component. The Component itself is inside a ScrollView.



      I am using map function to loop through the data to pass into the component.
      Earlier I was using ScrollView instead of FlatList. It was working fine, but was rendering slow. So I decided to use FlatList.



      Here's my code:



       renderComp()

      const filtersView,cats,cats_title, clearStyle = styles;

      const data = this.props.ingreds;

      const arr = Object.entries(data);


      return arr.map(i=>
      const name= i[0];
      const items_obj = i[1];
      const items = Object.values(items_obj);

      return(

      <View key=name style= filtersView>

      <View style=cats>

      <Text style =cats_title>name</Text>

      <Text style=clearStyle>Clear All</Text>
      </View>


      <View style=justifyContent:'flex-start', alignItems:'flex-start'>

      <FlatList
      style= marginRight:6
      data=items
      keyExtractor=(x,i)=> i.toString()
      renderItem=(item) =>
      this.renderItems(item)

      />
      </View>
      </View>

      )
      )




      And here's the ScrollView Component:



       <ScrollView contentContainerStyle=alignItems:'flex-start', 
      justifyContent:'flex-start',flex:1, height:72 >

      this.renderComp()

      </ScrollView>


      And The loop stops after one iteration.



      Here's the output: https://i.stack.imgur.com/yM151.png



      Any suggestions?










      share|improve this question














      I am trying to render a FlatList inside a component. The Component itself is inside a ScrollView.



      I am using map function to loop through the data to pass into the component.
      Earlier I was using ScrollView instead of FlatList. It was working fine, but was rendering slow. So I decided to use FlatList.



      Here's my code:



       renderComp()

      const filtersView,cats,cats_title, clearStyle = styles;

      const data = this.props.ingreds;

      const arr = Object.entries(data);


      return arr.map(i=>
      const name= i[0];
      const items_obj = i[1];
      const items = Object.values(items_obj);

      return(

      <View key=name style= filtersView>

      <View style=cats>

      <Text style =cats_title>name</Text>

      <Text style=clearStyle>Clear All</Text>
      </View>


      <View style=justifyContent:'flex-start', alignItems:'flex-start'>

      <FlatList
      style= marginRight:6
      data=items
      keyExtractor=(x,i)=> i.toString()
      renderItem=(item) =>
      this.renderItems(item)

      />
      </View>
      </View>

      )
      )




      And here's the ScrollView Component:



       <ScrollView contentContainerStyle=alignItems:'flex-start', 
      justifyContent:'flex-start',flex:1, height:72 >

      this.renderComp()

      </ScrollView>


      And The loop stops after one iteration.



      Here's the output: https://i.stack.imgur.com/yM151.png



      Any suggestions?







      javascript react-native react-native-flatlist






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 7:01









      Saumay PaulSaumay Paul

      9611




      9611






















          1 Answer
          1






          active

          oldest

          votes


















          1














          ReactNative FlatList renderItem method should return a ?React.Element component. In your case either use return this.renderItems or skip the inner brackets.



          https://facebook.github.io/react-native/docs/flatlist#renderitem



          (item) => this.renderItems(item)}





          share|improve this answer























          • Thanks!! That solved the FlatList rendering problem!!! But the renderComp() stops after one iteration. Now only one FlatList is being rendered.

            – Saumay Paul
            Mar 25 at 7:31











          • Is something wrong with arr.map() ??

            – Saumay Paul
            Mar 25 at 7:32











          • What are you trying to do with this arr.map ? create one FlatList for each array item ?

            – jgoday
            Mar 25 at 7:33











          • Yes! Render Components containing one FlatList

            – Saumay Paul
            Mar 25 at 7:38











          • If it's only one FlatList, you might want to avoid this map. Array.map will return a new array, applying a function over his items, so in your case, it will return a bunch of FlatList componentes. Return just one FlatList and pass the array to the data props. Am I wrong ?

            – jgoday
            Mar 25 at 7:39











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55332647%2funable-to-loop-and-render-flatlist-inside-map-function-react-native%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          ReactNative FlatList renderItem method should return a ?React.Element component. In your case either use return this.renderItems or skip the inner brackets.



          https://facebook.github.io/react-native/docs/flatlist#renderitem



          (item) => this.renderItems(item)}





          share|improve this answer























          • Thanks!! That solved the FlatList rendering problem!!! But the renderComp() stops after one iteration. Now only one FlatList is being rendered.

            – Saumay Paul
            Mar 25 at 7:31











          • Is something wrong with arr.map() ??

            – Saumay Paul
            Mar 25 at 7:32











          • What are you trying to do with this arr.map ? create one FlatList for each array item ?

            – jgoday
            Mar 25 at 7:33











          • Yes! Render Components containing one FlatList

            – Saumay Paul
            Mar 25 at 7:38











          • If it's only one FlatList, you might want to avoid this map. Array.map will return a new array, applying a function over his items, so in your case, it will return a bunch of FlatList componentes. Return just one FlatList and pass the array to the data props. Am I wrong ?

            – jgoday
            Mar 25 at 7:39















          1














          ReactNative FlatList renderItem method should return a ?React.Element component. In your case either use return this.renderItems or skip the inner brackets.



          https://facebook.github.io/react-native/docs/flatlist#renderitem



          (item) => this.renderItems(item)}





          share|improve this answer























          • Thanks!! That solved the FlatList rendering problem!!! But the renderComp() stops after one iteration. Now only one FlatList is being rendered.

            – Saumay Paul
            Mar 25 at 7:31











          • Is something wrong with arr.map() ??

            – Saumay Paul
            Mar 25 at 7:32











          • What are you trying to do with this arr.map ? create one FlatList for each array item ?

            – jgoday
            Mar 25 at 7:33











          • Yes! Render Components containing one FlatList

            – Saumay Paul
            Mar 25 at 7:38











          • If it's only one FlatList, you might want to avoid this map. Array.map will return a new array, applying a function over his items, so in your case, it will return a bunch of FlatList componentes. Return just one FlatList and pass the array to the data props. Am I wrong ?

            – jgoday
            Mar 25 at 7:39













          1












          1








          1







          ReactNative FlatList renderItem method should return a ?React.Element component. In your case either use return this.renderItems or skip the inner brackets.



          https://facebook.github.io/react-native/docs/flatlist#renderitem



          (item) => this.renderItems(item)}





          share|improve this answer













          ReactNative FlatList renderItem method should return a ?React.Element component. In your case either use return this.renderItems or skip the inner brackets.



          https://facebook.github.io/react-native/docs/flatlist#renderitem



          (item) => this.renderItems(item)}






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 25 at 7:12









          jgodayjgoday

          1,85211014




          1,85211014












          • Thanks!! That solved the FlatList rendering problem!!! But the renderComp() stops after one iteration. Now only one FlatList is being rendered.

            – Saumay Paul
            Mar 25 at 7:31











          • Is something wrong with arr.map() ??

            – Saumay Paul
            Mar 25 at 7:32











          • What are you trying to do with this arr.map ? create one FlatList for each array item ?

            – jgoday
            Mar 25 at 7:33











          • Yes! Render Components containing one FlatList

            – Saumay Paul
            Mar 25 at 7:38











          • If it's only one FlatList, you might want to avoid this map. Array.map will return a new array, applying a function over his items, so in your case, it will return a bunch of FlatList componentes. Return just one FlatList and pass the array to the data props. Am I wrong ?

            – jgoday
            Mar 25 at 7:39

















          • Thanks!! That solved the FlatList rendering problem!!! But the renderComp() stops after one iteration. Now only one FlatList is being rendered.

            – Saumay Paul
            Mar 25 at 7:31











          • Is something wrong with arr.map() ??

            – Saumay Paul
            Mar 25 at 7:32











          • What are you trying to do with this arr.map ? create one FlatList for each array item ?

            – jgoday
            Mar 25 at 7:33











          • Yes! Render Components containing one FlatList

            – Saumay Paul
            Mar 25 at 7:38











          • If it's only one FlatList, you might want to avoid this map. Array.map will return a new array, applying a function over his items, so in your case, it will return a bunch of FlatList componentes. Return just one FlatList and pass the array to the data props. Am I wrong ?

            – jgoday
            Mar 25 at 7:39
















          Thanks!! That solved the FlatList rendering problem!!! But the renderComp() stops after one iteration. Now only one FlatList is being rendered.

          – Saumay Paul
          Mar 25 at 7:31





          Thanks!! That solved the FlatList rendering problem!!! But the renderComp() stops after one iteration. Now only one FlatList is being rendered.

          – Saumay Paul
          Mar 25 at 7:31













          Is something wrong with arr.map() ??

          – Saumay Paul
          Mar 25 at 7:32





          Is something wrong with arr.map() ??

          – Saumay Paul
          Mar 25 at 7:32













          What are you trying to do with this arr.map ? create one FlatList for each array item ?

          – jgoday
          Mar 25 at 7:33





          What are you trying to do with this arr.map ? create one FlatList for each array item ?

          – jgoday
          Mar 25 at 7:33













          Yes! Render Components containing one FlatList

          – Saumay Paul
          Mar 25 at 7:38





          Yes! Render Components containing one FlatList

          – Saumay Paul
          Mar 25 at 7:38













          If it's only one FlatList, you might want to avoid this map. Array.map will return a new array, applying a function over his items, so in your case, it will return a bunch of FlatList componentes. Return just one FlatList and pass the array to the data props. Am I wrong ?

          – jgoday
          Mar 25 at 7:39





          If it's only one FlatList, you might want to avoid this map. Array.map will return a new array, applying a function over his items, so in your case, it will return a bunch of FlatList componentes. Return just one FlatList and pass the array to the data props. Am I wrong ?

          – jgoday
          Mar 25 at 7:39



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55332647%2funable-to-loop-and-render-flatlist-inside-map-function-react-native%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현