1

For example , declared activeTabIndex

How to see if i am setting the activeTabIndex event?

Here is the code:

 <TouchableOpacity onPress={() => setActiveTabIndex(0)} style={{ width: Dimensions.get("window").width / 4, padding: 5, alignItems: "center" }}>
          <Home height={30} width={22} fill={activeTabIndex == 0 ? "blue" : "#d4e6f1"} />
        </TouchableOpacity>

Where to write console.log(activeTabIndex) or something)

  • 1
    `{activeTabIndex}` between the opening and closing JSX tags... – DecPK Jun 28 '21 at 07:19
  • on developer tools, console.log(activeTabIndex) didnt work –  Jun 28 '21 at 07:20
  • 1
    you don't have to use `console.log` just use `{activeTabIndex}` in the HTML and the value will get printed in the HTML. – DecPK Jun 28 '21 at 07:21
  • In `setActiveTabIndex` function have `console.log(whateverVarIsPassed)` – mplungjan Jun 28 '21 at 07:21
  • I just couldnt understand.. I mean i want to write to the console itself. `setActiveTabIndex()` this only sets the State, it wouldnt make sense if i wrote `setTabIndex(console.log(activeTabIndex)` because i set in there, if i wrote this, it wouldnt be set –  Jun 28 '21 at 07:36
  • 1
    That does not make any sense. - you could do console.log(setTabIndex (activeTabIndex)) and return the tabIndex if you wanted, but not the other way around – mplungjan Jun 28 '21 at 07:47
  • Okay Sir, thank you –  Jun 28 '21 at 07:53
  • @mplungjan could u please look at my question if u have free time? Thank you, https://stackoverflow.com/questions/68165896/why-doesnt-tab-bar-icon-color-change?noredirect=1#comment120475827_68165896 –  Jun 29 '21 at 06:32

1 Answers1

-1
  1. You can bind activeTabIndex to your JSX template eg. {activeTabIndex}
  2. You could add a console.log(index) in your setActiveTabIndex() method to see if it is getting fired.
  • This is basically a consolidation of comments to the question. The question is not worth answering and should be deleted – mplungjan Jun 28 '21 at 07:29
  • I just couldnt understand.. I mean i want to write to the console itself. `setActiveTabIndex()` this only sets the State, it wouldnt make sense if i wrote `setTabIndex(console.log(activeTabIndex)` because i set in there, if i wrote this, it wouldnt be set –  Jun 28 '21 at 07:40