How to use map function to Mobx observable state?How to update parent's state in React?Export and import observable MobX React NativeReacting to changes within observed object's unobserved propertiesMobX, and connection between storesStore change doesn't re-render computed function in componentreact native snap carousel tinder animation not working for multiple slides getting hangedhandleChange with React and MobxUsing mobx with redux in the same project - even in the same component/classModalFilterPicker load more on scrollHow to fix this error 'undefined is not an object'?

If there were no space agencies, could a person go to space?

sytemctl status log output

In Pokémon Go, why does one of my Pikachu have an option to evolve, but another one doesn't?

Unexpected route on a flight from USA to Europe

Short story about a teenager who has his brain replaced with a microchip (Psychological Horror)

Did Apollo leave poop on the moon?

Should I self-publish my novella on Amazon or try my luck getting publishers?

What does VB stand for?

Double blind peer review when paper cites author's GitHub repo for code

Is it allowed and safe to carry a passenger / non-pilot in the front seat of a small general aviation airplane?

Why do private jets such as Gulfstream fly higher than other civilian jets?

Does the Voyager team use a wrapper (Fortran(77?) to Python) to transmit current commands?

Decode a variable-length quantity

Look mom! I made my own (Base 10) numeral system!

How can glass marbles naturally occur in a desert?

How quickly could a country build a tall concrete wall around a city?

What was the first multiprocessor x86 motherboard?

Traveling from Germany to other countries by train?

What are the examples (applications) of the MIPs in which the objective function has nonzero coefficients for only continuous variables?

Is TEXT to VARCHAR(MAX) an implicit conversion?

How to help new students accept function notation

What are good ways to improve as a writer other than writing courses?

Is this cheap "air conditioner" able to cool a room?

In the movie Harry Potter and the Order or the Phoenix, why didn't Mr. Filch succeed to open the Room of Requirement if it's what he needed?



How to use map function to Mobx observable state?


How to update parent's state in React?Export and import observable MobX React NativeReacting to changes within observed object's unobserved propertiesMobX, and connection between storesStore change doesn't re-render computed function in componentreact native snap carousel tinder animation not working for multiple slides getting hangedhandleChange with React and MobxUsing mobx with redux in the same project - even in the same component/classModalFilterPicker load more on scrollHow to fix this error 'undefined is not an object'?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Now I would like to use Map function to show a component with each array.



But, my code with map is not working rightly.
In firestore, there are 3 document in "food" collection but this map function can only render one document.



This is my code below in render component.



renderItemBox() 
const store = this.props;
const items = store.restaurantStore.Items;
return items.map((value, index) =>
console.log(items);
return (
<TouchableOpacity key=index>
<View style=styles.itemsBox>
<View style=styles.itemsImageBox>
<Image
source=require('../../assets/Images/Home/HomeListImageShop.jpg')
style=styles.itemsImage
/>
</View>
<View style= flexDirection: 'row' >
<Text style=styles.itemsName>
value[index].name
</Text>
<Text style=styles.itemsTag>
value[index].tag
</Text>
</View>

<View style= flexDirection: 'row' >
<Text style=styles.itemsDescription>
value[index].shortDescription
</Text>
<TouchableOpacity
style=styles.likeButtonBox
onPress=this.handleLikeButton.bind(this)
>
this.handleLikeImage()
</TouchableOpacity>
</View>
</View>
</TouchableOpacity>
);
);



In addition to this, I set store component in my project.
This code above is importing observable state(array) from that store.



Below one is that store.



import observable, action from 'mobx';
import firebase from 'firebase';

class RestaurantStore
@observable Items = [];

@action handleFirestoreCollectionOfFoods ()
const db = firebase.firestore();
db.collection('foods')
.get()
.then((snapshot) =>
const preItems = [];
snapshot.forEach((doc) =>
const docData = doc.data();
preItems.push(docData);
);
this.Items.push(preItems);
)
.catch((error) =>
console.log(error);
);



export default RestaurantStore;



Fortunetely, this store can import complete document from firestore.
I did check that with console.log.



So, does someone know how to use map function to mobx state completely?










share|improve this question
























  • It's not related to map function. do you mark the component as observer ?!

    – Ehsan Majdabadi
    Mar 27 at 6:12











  • Sure, and in the component with map function, I can get the observerbaleArray from mobx store. But I cannot render all of array with map

    – ryonz
    Mar 27 at 6:13











  • Try to mock items array and check the output. I think render logic should be revised. Map and observable arrays work very well together.

    – Ehsan Majdabadi
    Mar 27 at 6:25












  • I did that before. In that time, all of the objects in an array can be rendered by map function. I have just replaced that object array and function to import data from firestore to store component.

    – ryonz
    Mar 27 at 6:30











  • Have you provided the instantiated const restaurantStore = new RestaurantStore() ?

    – samb102
    Mar 27 at 8:55

















0















Now I would like to use Map function to show a component with each array.



But, my code with map is not working rightly.
In firestore, there are 3 document in "food" collection but this map function can only render one document.



This is my code below in render component.



renderItemBox() 
const store = this.props;
const items = store.restaurantStore.Items;
return items.map((value, index) =>
console.log(items);
return (
<TouchableOpacity key=index>
<View style=styles.itemsBox>
<View style=styles.itemsImageBox>
<Image
source=require('../../assets/Images/Home/HomeListImageShop.jpg')
style=styles.itemsImage
/>
</View>
<View style= flexDirection: 'row' >
<Text style=styles.itemsName>
value[index].name
</Text>
<Text style=styles.itemsTag>
value[index].tag
</Text>
</View>

<View style= flexDirection: 'row' >
<Text style=styles.itemsDescription>
value[index].shortDescription
</Text>
<TouchableOpacity
style=styles.likeButtonBox
onPress=this.handleLikeButton.bind(this)
>
this.handleLikeImage()
</TouchableOpacity>
</View>
</View>
</TouchableOpacity>
);
);



In addition to this, I set store component in my project.
This code above is importing observable state(array) from that store.



Below one is that store.



import observable, action from 'mobx';
import firebase from 'firebase';

class RestaurantStore
@observable Items = [];

@action handleFirestoreCollectionOfFoods ()
const db = firebase.firestore();
db.collection('foods')
.get()
.then((snapshot) =>
const preItems = [];
snapshot.forEach((doc) =>
const docData = doc.data();
preItems.push(docData);
);
this.Items.push(preItems);
)
.catch((error) =>
console.log(error);
);



export default RestaurantStore;



Fortunetely, this store can import complete document from firestore.
I did check that with console.log.



So, does someone know how to use map function to mobx state completely?










share|improve this question
























  • It's not related to map function. do you mark the component as observer ?!

    – Ehsan Majdabadi
    Mar 27 at 6:12











  • Sure, and in the component with map function, I can get the observerbaleArray from mobx store. But I cannot render all of array with map

    – ryonz
    Mar 27 at 6:13











  • Try to mock items array and check the output. I think render logic should be revised. Map and observable arrays work very well together.

    – Ehsan Majdabadi
    Mar 27 at 6:25












  • I did that before. In that time, all of the objects in an array can be rendered by map function. I have just replaced that object array and function to import data from firestore to store component.

    – ryonz
    Mar 27 at 6:30











  • Have you provided the instantiated const restaurantStore = new RestaurantStore() ?

    – samb102
    Mar 27 at 8:55













0












0








0








Now I would like to use Map function to show a component with each array.



But, my code with map is not working rightly.
In firestore, there are 3 document in "food" collection but this map function can only render one document.



This is my code below in render component.



renderItemBox() 
const store = this.props;
const items = store.restaurantStore.Items;
return items.map((value, index) =>
console.log(items);
return (
<TouchableOpacity key=index>
<View style=styles.itemsBox>
<View style=styles.itemsImageBox>
<Image
source=require('../../assets/Images/Home/HomeListImageShop.jpg')
style=styles.itemsImage
/>
</View>
<View style= flexDirection: 'row' >
<Text style=styles.itemsName>
value[index].name
</Text>
<Text style=styles.itemsTag>
value[index].tag
</Text>
</View>

<View style= flexDirection: 'row' >
<Text style=styles.itemsDescription>
value[index].shortDescription
</Text>
<TouchableOpacity
style=styles.likeButtonBox
onPress=this.handleLikeButton.bind(this)
>
this.handleLikeImage()
</TouchableOpacity>
</View>
</View>
</TouchableOpacity>
);
);



In addition to this, I set store component in my project.
This code above is importing observable state(array) from that store.



Below one is that store.



import observable, action from 'mobx';
import firebase from 'firebase';

class RestaurantStore
@observable Items = [];

@action handleFirestoreCollectionOfFoods ()
const db = firebase.firestore();
db.collection('foods')
.get()
.then((snapshot) =>
const preItems = [];
snapshot.forEach((doc) =>
const docData = doc.data();
preItems.push(docData);
);
this.Items.push(preItems);
)
.catch((error) =>
console.log(error);
);



export default RestaurantStore;



Fortunetely, this store can import complete document from firestore.
I did check that with console.log.



So, does someone know how to use map function to mobx state completely?










share|improve this question














Now I would like to use Map function to show a component with each array.



But, my code with map is not working rightly.
In firestore, there are 3 document in "food" collection but this map function can only render one document.



This is my code below in render component.



renderItemBox() 
const store = this.props;
const items = store.restaurantStore.Items;
return items.map((value, index) =>
console.log(items);
return (
<TouchableOpacity key=index>
<View style=styles.itemsBox>
<View style=styles.itemsImageBox>
<Image
source=require('../../assets/Images/Home/HomeListImageShop.jpg')
style=styles.itemsImage
/>
</View>
<View style= flexDirection: 'row' >
<Text style=styles.itemsName>
value[index].name
</Text>
<Text style=styles.itemsTag>
value[index].tag
</Text>
</View>

<View style= flexDirection: 'row' >
<Text style=styles.itemsDescription>
value[index].shortDescription
</Text>
<TouchableOpacity
style=styles.likeButtonBox
onPress=this.handleLikeButton.bind(this)
>
this.handleLikeImage()
</TouchableOpacity>
</View>
</View>
</TouchableOpacity>
);
);



In addition to this, I set store component in my project.
This code above is importing observable state(array) from that store.



Below one is that store.



import observable, action from 'mobx';
import firebase from 'firebase';

class RestaurantStore
@observable Items = [];

@action handleFirestoreCollectionOfFoods ()
const db = firebase.firestore();
db.collection('foods')
.get()
.then((snapshot) =>
const preItems = [];
snapshot.forEach((doc) =>
const docData = doc.data();
preItems.push(docData);
);
this.Items.push(preItems);
)
.catch((error) =>
console.log(error);
);



export default RestaurantStore;



Fortunetely, this store can import complete document from firestore.
I did check that with console.log.



So, does someone know how to use map function to mobx state completely?







reactjs react-native expo mobx






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 6:00









ryonzryonz

1069 bronze badges




1069 bronze badges















  • It's not related to map function. do you mark the component as observer ?!

    – Ehsan Majdabadi
    Mar 27 at 6:12











  • Sure, and in the component with map function, I can get the observerbaleArray from mobx store. But I cannot render all of array with map

    – ryonz
    Mar 27 at 6:13











  • Try to mock items array and check the output. I think render logic should be revised. Map and observable arrays work very well together.

    – Ehsan Majdabadi
    Mar 27 at 6:25












  • I did that before. In that time, all of the objects in an array can be rendered by map function. I have just replaced that object array and function to import data from firestore to store component.

    – ryonz
    Mar 27 at 6:30











  • Have you provided the instantiated const restaurantStore = new RestaurantStore() ?

    – samb102
    Mar 27 at 8:55

















  • It's not related to map function. do you mark the component as observer ?!

    – Ehsan Majdabadi
    Mar 27 at 6:12











  • Sure, and in the component with map function, I can get the observerbaleArray from mobx store. But I cannot render all of array with map

    – ryonz
    Mar 27 at 6:13











  • Try to mock items array and check the output. I think render logic should be revised. Map and observable arrays work very well together.

    – Ehsan Majdabadi
    Mar 27 at 6:25












  • I did that before. In that time, all of the objects in an array can be rendered by map function. I have just replaced that object array and function to import data from firestore to store component.

    – ryonz
    Mar 27 at 6:30











  • Have you provided the instantiated const restaurantStore = new RestaurantStore() ?

    – samb102
    Mar 27 at 8:55
















It's not related to map function. do you mark the component as observer ?!

– Ehsan Majdabadi
Mar 27 at 6:12





It's not related to map function. do you mark the component as observer ?!

– Ehsan Majdabadi
Mar 27 at 6:12













Sure, and in the component with map function, I can get the observerbaleArray from mobx store. But I cannot render all of array with map

– ryonz
Mar 27 at 6:13





Sure, and in the component with map function, I can get the observerbaleArray from mobx store. But I cannot render all of array with map

– ryonz
Mar 27 at 6:13













Try to mock items array and check the output. I think render logic should be revised. Map and observable arrays work very well together.

– Ehsan Majdabadi
Mar 27 at 6:25






Try to mock items array and check the output. I think render logic should be revised. Map and observable arrays work very well together.

– Ehsan Majdabadi
Mar 27 at 6:25














I did that before. In that time, all of the objects in an array can be rendered by map function. I have just replaced that object array and function to import data from firestore to store component.

– ryonz
Mar 27 at 6:30





I did that before. In that time, all of the objects in an array can be rendered by map function. I have just replaced that object array and function to import data from firestore to store component.

– ryonz
Mar 27 at 6:30













Have you provided the instantiated const restaurantStore = new RestaurantStore() ?

– samb102
Mar 27 at 8:55





Have you provided the instantiated const restaurantStore = new RestaurantStore() ?

– samb102
Mar 27 at 8:55












0






active

oldest

votes










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%2f55370715%2fhow-to-use-map-function-to-mobx-observable-state%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















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%2f55370715%2fhow-to-use-map-function-to-mobx-observable-state%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권, 지리지 충청도 공주목 은진현