How to map an array of objects stored in Redux inside the render() using ES6React-Native + Redux: fetching data from API as an array of objects and rendering in list componentReact Native setState in component updating redux storeReact-Native ListView with Object ArrayHow redux work when multiple components use parts of complex objects for it's sourceReact native + redux + empty objectMap state to props not updating after ReduxHow to pass JSON data to react-native-maps-super-clusterHow to fix this error 'undefined is not an object'?React Native FlatList won't re-render when the last element in an array deletedError when I was trying to render a map of items

What to do if SUS scores contradict qualitative feedback?

correct spelling of "carruffel" (fuzz, hustle, all that jazz)

What are the holes in files created with fallocate?

In books, how many dragons are there in present time?

Is the circle homeomorphic to a 6 petal rose?

Is there any good reason to write "it is easy to see"?

On what legal basis did the UK remove the 'European Union' from its passport?

Interior smooth regularity

Why was Endgame Thanos so different than Infinity War Thanos?

LWC1513: @salesforce/resourceUrl modules only support default imports

Does SQL Server allow (make visible) DDL inside a transaction to the transaction prior to commit?

How to cope with regret and shame about not fully utilizing opportunities during PhD?

Why is it harder to turn a motor/generator with shorted terminals?

Why does my circuit work on a breadboard, but not on a perfboard? I am new to soldering

How exactly does artificial gravity work?

Unbounded Fredholms operators

Is it practical to use a slug-tuned variable inductor in an antenna matcher (aka "antenna tuner")?

Centering subcaptions in a tikz pgfplot subfigure environment?

What's the difference between "за ... от" and "в ... от"?

Replace all items that are not belong to characters and numbers by ' '

Frame adjustment for engine

What is the best way for a skeleton to impersonate human without using magic?

Ex-manager wants to stay in touch, I don't want to

Why does the Earth follow an elliptical trajectory rather than a parabolic one?



How to map an array of objects stored in Redux inside the render() using ES6


React-Native + Redux: fetching data from API as an array of objects and rendering in list componentReact Native setState in component updating redux storeReact-Native ListView with Object ArrayHow redux work when multiple components use parts of complex objects for it's sourceReact native + redux + empty objectMap state to props not updating after ReduxHow to pass JSON data to react-native-maps-super-clusterHow to fix this error 'undefined is not an object'?React Native FlatList won't re-render when the last element in an array deletedError when I was trying to render a map of items






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








-2















New to RN and trying to understand object mapping. I can't seem to get the StackO answers similar to this to work in my app. I'd get this.props.locations was undefined, so I initialized the object with the object 'latlons' you see in the data structure below.



this.props.locations




"latlons":
"latitude": "0",
"longitude": "0",
"accuracy": "0"
,
"0":
"latitude": 37.33382825,
"longitude": -122.07735141,
"accuracy": 5
,
"1":
"latitude": 37.35304318,
"longitude": -122.1073468,
"accuracy": 5
,
"2":
"latitude": 37.37664016,
"longitude": -122.14817958,
"accuracy": 5
,
"3":
"latitude": 37.38885423,
"longitude": -122.15958014,
"accuracy": 5
,
"4":
"latitude": 37.40479565,
"longitude": -122.1870328,
"accuracy": 5
,
"5":
"latitude": 37.412672,
"longitude": -122.20550149,
"accuracy": 5




As I'm using RN 0.59.1 and React 16.8, I tried:



 render() 
const Test = (locations) => (
<>
this.props.locations.map(locations => (
<Text> key=locations.latitude locations.longitude</Text>
))
</>
);

return (
<View style=styles.container>
<View>
Test
</View>
</View>
);



But it doesn't print anything in the view. What am doing wrong?



Edit: I do have Redux configured correctly, because if I console.log(this.props.locations) it'll show me the correct data structure above. So just having trouble mapping to the rendered component.










share|improve this question






















  • does your data is really an object. if that is the case, you can't map it.

    – Mervzs
    Mar 23 at 13:21

















-2















New to RN and trying to understand object mapping. I can't seem to get the StackO answers similar to this to work in my app. I'd get this.props.locations was undefined, so I initialized the object with the object 'latlons' you see in the data structure below.



this.props.locations




"latlons":
"latitude": "0",
"longitude": "0",
"accuracy": "0"
,
"0":
"latitude": 37.33382825,
"longitude": -122.07735141,
"accuracy": 5
,
"1":
"latitude": 37.35304318,
"longitude": -122.1073468,
"accuracy": 5
,
"2":
"latitude": 37.37664016,
"longitude": -122.14817958,
"accuracy": 5
,
"3":
"latitude": 37.38885423,
"longitude": -122.15958014,
"accuracy": 5
,
"4":
"latitude": 37.40479565,
"longitude": -122.1870328,
"accuracy": 5
,
"5":
"latitude": 37.412672,
"longitude": -122.20550149,
"accuracy": 5




As I'm using RN 0.59.1 and React 16.8, I tried:



 render() 
const Test = (locations) => (
<>
this.props.locations.map(locations => (
<Text> key=locations.latitude locations.longitude</Text>
))
</>
);

return (
<View style=styles.container>
<View>
Test
</View>
</View>
);



But it doesn't print anything in the view. What am doing wrong?



Edit: I do have Redux configured correctly, because if I console.log(this.props.locations) it'll show me the correct data structure above. So just having trouble mapping to the rendered component.










share|improve this question






















  • does your data is really an object. if that is the case, you can't map it.

    – Mervzs
    Mar 23 at 13:21













-2












-2








-2








New to RN and trying to understand object mapping. I can't seem to get the StackO answers similar to this to work in my app. I'd get this.props.locations was undefined, so I initialized the object with the object 'latlons' you see in the data structure below.



this.props.locations




"latlons":
"latitude": "0",
"longitude": "0",
"accuracy": "0"
,
"0":
"latitude": 37.33382825,
"longitude": -122.07735141,
"accuracy": 5
,
"1":
"latitude": 37.35304318,
"longitude": -122.1073468,
"accuracy": 5
,
"2":
"latitude": 37.37664016,
"longitude": -122.14817958,
"accuracy": 5
,
"3":
"latitude": 37.38885423,
"longitude": -122.15958014,
"accuracy": 5
,
"4":
"latitude": 37.40479565,
"longitude": -122.1870328,
"accuracy": 5
,
"5":
"latitude": 37.412672,
"longitude": -122.20550149,
"accuracy": 5




As I'm using RN 0.59.1 and React 16.8, I tried:



 render() 
const Test = (locations) => (
<>
this.props.locations.map(locations => (
<Text> key=locations.latitude locations.longitude</Text>
))
</>
);

return (
<View style=styles.container>
<View>
Test
</View>
</View>
);



But it doesn't print anything in the view. What am doing wrong?



Edit: I do have Redux configured correctly, because if I console.log(this.props.locations) it'll show me the correct data structure above. So just having trouble mapping to the rendered component.










share|improve this question














New to RN and trying to understand object mapping. I can't seem to get the StackO answers similar to this to work in my app. I'd get this.props.locations was undefined, so I initialized the object with the object 'latlons' you see in the data structure below.



this.props.locations




"latlons":
"latitude": "0",
"longitude": "0",
"accuracy": "0"
,
"0":
"latitude": 37.33382825,
"longitude": -122.07735141,
"accuracy": 5
,
"1":
"latitude": 37.35304318,
"longitude": -122.1073468,
"accuracy": 5
,
"2":
"latitude": 37.37664016,
"longitude": -122.14817958,
"accuracy": 5
,
"3":
"latitude": 37.38885423,
"longitude": -122.15958014,
"accuracy": 5
,
"4":
"latitude": 37.40479565,
"longitude": -122.1870328,
"accuracy": 5
,
"5":
"latitude": 37.412672,
"longitude": -122.20550149,
"accuracy": 5




As I'm using RN 0.59.1 and React 16.8, I tried:



 render() 
const Test = (locations) => (
<>
this.props.locations.map(locations => (
<Text> key=locations.latitude locations.longitude</Text>
))
</>
);

return (
<View style=styles.container>
<View>
Test
</View>
</View>
);



But it doesn't print anything in the view. What am doing wrong?



Edit: I do have Redux configured correctly, because if I console.log(this.props.locations) it'll show me the correct data structure above. So just having trouble mapping to the rendered component.







react-native






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 23 at 13:05









Levi BeersLevi Beers

1




1












  • does your data is really an object. if that is the case, you can't map it.

    – Mervzs
    Mar 23 at 13:21

















  • does your data is really an object. if that is the case, you can't map it.

    – Mervzs
    Mar 23 at 13:21
















does your data is really an object. if that is the case, you can't map it.

– Mervzs
Mar 23 at 13:21





does your data is really an object. if that is the case, you can't map it.

– Mervzs
Mar 23 at 13:21












1 Answer
1






active

oldest

votes


















0














Try to change your data structure into an array,



Like This:



 example = [

"latitude": "0",
"longitude": "0",
"accuracy": "0"
,

"latitude": 37.33382825,
"longitude": -122.07735141,
"accuracy": 5
,

"latitude": 37.35304318,
"longitude": -122.1073468,
"accuracy": 5
,

"latitude": 37.37664016,
"longitude": -122.14817958,
"accuracy": 5
,

"latitude": 37.38885423,
"longitude": -122.15958014,
"accuracy": 5
,

"latitude": 37.40479565,
"longitude": -122.1870328,
"accuracy": 5
,

"latitude": 37.412672,
"longitude": -122.20550149,
"accuracy": 5

]


Edited 1:



in addition i think one of your mistake is you pass a function inside render. modify your const test just a normal component value



Like this:



 render() 
const Test = (
<>
sample.map(locations => (
<Text> key=locations.latitude locations.longitude</Text>
))
</>
);

return (
<View style=styles.container>
<View>
Test
</View>
</View>
);

}


It will work now. Hope it helps :D






share|improve this answer

























  • Thank you! After changing my data structure I'm able to access the data.

    – Levi Beers
    Mar 23 at 13:54











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%2f55314015%2fhow-to-map-an-array-of-objects-stored-in-redux-inside-the-render-using-es6%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









0














Try to change your data structure into an array,



Like This:



 example = [

"latitude": "0",
"longitude": "0",
"accuracy": "0"
,

"latitude": 37.33382825,
"longitude": -122.07735141,
"accuracy": 5
,

"latitude": 37.35304318,
"longitude": -122.1073468,
"accuracy": 5
,

"latitude": 37.37664016,
"longitude": -122.14817958,
"accuracy": 5
,

"latitude": 37.38885423,
"longitude": -122.15958014,
"accuracy": 5
,

"latitude": 37.40479565,
"longitude": -122.1870328,
"accuracy": 5
,

"latitude": 37.412672,
"longitude": -122.20550149,
"accuracy": 5

]


Edited 1:



in addition i think one of your mistake is you pass a function inside render. modify your const test just a normal component value



Like this:



 render() 
const Test = (
<>
sample.map(locations => (
<Text> key=locations.latitude locations.longitude</Text>
))
</>
);

return (
<View style=styles.container>
<View>
Test
</View>
</View>
);

}


It will work now. Hope it helps :D






share|improve this answer

























  • Thank you! After changing my data structure I'm able to access the data.

    – Levi Beers
    Mar 23 at 13:54















0














Try to change your data structure into an array,



Like This:



 example = [

"latitude": "0",
"longitude": "0",
"accuracy": "0"
,

"latitude": 37.33382825,
"longitude": -122.07735141,
"accuracy": 5
,

"latitude": 37.35304318,
"longitude": -122.1073468,
"accuracy": 5
,

"latitude": 37.37664016,
"longitude": -122.14817958,
"accuracy": 5
,

"latitude": 37.38885423,
"longitude": -122.15958014,
"accuracy": 5
,

"latitude": 37.40479565,
"longitude": -122.1870328,
"accuracy": 5
,

"latitude": 37.412672,
"longitude": -122.20550149,
"accuracy": 5

]


Edited 1:



in addition i think one of your mistake is you pass a function inside render. modify your const test just a normal component value



Like this:



 render() 
const Test = (
<>
sample.map(locations => (
<Text> key=locations.latitude locations.longitude</Text>
))
</>
);

return (
<View style=styles.container>
<View>
Test
</View>
</View>
);

}


It will work now. Hope it helps :D






share|improve this answer

























  • Thank you! After changing my data structure I'm able to access the data.

    – Levi Beers
    Mar 23 at 13:54













0












0








0







Try to change your data structure into an array,



Like This:



 example = [

"latitude": "0",
"longitude": "0",
"accuracy": "0"
,

"latitude": 37.33382825,
"longitude": -122.07735141,
"accuracy": 5
,

"latitude": 37.35304318,
"longitude": -122.1073468,
"accuracy": 5
,

"latitude": 37.37664016,
"longitude": -122.14817958,
"accuracy": 5
,

"latitude": 37.38885423,
"longitude": -122.15958014,
"accuracy": 5
,

"latitude": 37.40479565,
"longitude": -122.1870328,
"accuracy": 5
,

"latitude": 37.412672,
"longitude": -122.20550149,
"accuracy": 5

]


Edited 1:



in addition i think one of your mistake is you pass a function inside render. modify your const test just a normal component value



Like this:



 render() 
const Test = (
<>
sample.map(locations => (
<Text> key=locations.latitude locations.longitude</Text>
))
</>
);

return (
<View style=styles.container>
<View>
Test
</View>
</View>
);

}


It will work now. Hope it helps :D






share|improve this answer















Try to change your data structure into an array,



Like This:



 example = [

"latitude": "0",
"longitude": "0",
"accuracy": "0"
,

"latitude": 37.33382825,
"longitude": -122.07735141,
"accuracy": 5
,

"latitude": 37.35304318,
"longitude": -122.1073468,
"accuracy": 5
,

"latitude": 37.37664016,
"longitude": -122.14817958,
"accuracy": 5
,

"latitude": 37.38885423,
"longitude": -122.15958014,
"accuracy": 5
,

"latitude": 37.40479565,
"longitude": -122.1870328,
"accuracy": 5
,

"latitude": 37.412672,
"longitude": -122.20550149,
"accuracy": 5

]


Edited 1:



in addition i think one of your mistake is you pass a function inside render. modify your const test just a normal component value



Like this:



 render() 
const Test = (
<>
sample.map(locations => (
<Text> key=locations.latitude locations.longitude</Text>
))
</>
);

return (
<View style=styles.container>
<View>
Test
</View>
</View>
);

}


It will work now. Hope it helps :D







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 23 at 13:32

























answered Mar 23 at 13:25









MervzsMervzs

54814




54814












  • Thank you! After changing my data structure I'm able to access the data.

    – Levi Beers
    Mar 23 at 13:54

















  • Thank you! After changing my data structure I'm able to access the data.

    – Levi Beers
    Mar 23 at 13:54
















Thank you! After changing my data structure I'm able to access the data.

– Levi Beers
Mar 23 at 13:54





Thank you! After changing my data structure I'm able to access the data.

– Levi Beers
Mar 23 at 13:54



















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%2f55314015%2fhow-to-map-an-array-of-objects-stored-in-redux-inside-the-render-using-es6%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

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

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해