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;
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
|
show 1 more comment
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
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 instantiatedconst restaurantStore = new RestaurantStore()
?
– samb102
Mar 27 at 8:55
|
show 1 more comment
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
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
reactjs react-native expo mobx
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 instantiatedconst restaurantStore = new RestaurantStore()
?
– samb102
Mar 27 at 8:55
|
show 1 more comment
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 instantiatedconst 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
|
show 1 more comment
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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