Answer the question
In order to leave comments, you need to log in
How to pass a value to state from another page?
For routing I use react-navigation.
There are two pages:
HomePage (main page).
HomePageList(main page only all items in list view) What I
need to do is:
When I click on an item from the list on the HomePageList page. Should pass the value in state to the HomePage.
Let's say I click on item 12 on the HomePageList page.
On HomePage, 12 should be passed to state activeSlide.
Answer the question
In order to leave comments, you need to log in
async ActiveSlide() {
let value = await this.props.navigation.getParam("index");
if (value !== undefined) {
await this.setState({ //вот тут изменения
activeSlide: value
});
this.props.navigation.state.params.index = undefined;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question