如何从对象的函数中获取返回值

时间:2019-11-07 09:40:13

标签: javascript react-native ecmascript-6 react-navigation ecmascript-5

我想从对象中的函数获取返回值

它可以在对象中调用函数,但我无法获得返回值

我应该怎么做

const depthCheck = state => {
  let index = state.index === undefined ? null : state.index;
  if (index !== null) {
    depthCheck(state.routes[index]);
  } else {
    console.log(state);
    return state;
  }
};

const RootStack = createStackNavigator(
  {
    TabNavigator,
  },
  {
    defaultNavigationOptions: ({ navigation }) => (
      //call function but i cant get return value from console
      console.log(depthCheck(navigation.state))
    ),
  },
);

0 个答案:

没有答案