-1

Now I would like to get a variable from if inside same function as if like below.

renderItemBox() {
const { store } = this.props;
const currentScreen = this.props.navigation.state.routeName;
AsyncStorage.getItem('openingGenre')
  .then((openingGenreValue) => {
    if (currentScreen === 'EachShopGenreScreen') {
      if (openingGenreValue === 'food') {
        const items = this.store.restourantStore.Items;
      } else {
        Alert.alert('予期せぬ不具合が発生いたしました。再度お試し下さい');
      }
  });
return items.map((value, index) => (


//////
)

However, this code is not working, I cannot get "items" from IF on items.map~~~~

Why this is happening?

Could someone help me.

ryonz
  • 441
  • 2
  • 8
  • 19

1 Answers1

0

You need to declare items using let as an empty array in the function scope then do your if statement. Or at least that's one way of doing it. Btw this is more of a JavaScript question.

Sam Lahm
  • 93
  • 1
  • 10