【发布时间】:2019-01-14 22:15:17
【问题描述】:
我下面的代码不会运行 if 语句,只会运行 else。
SecureStore.getItemAsync('notFirstLaunch').then((value) => {
LaunchApp(value);
});
const LaunchApp = function (value) {
console.log(value);
if (value === "true") {
return (
<SafeAreaView forceInset={{ bottom: 0 }} style={{ flex: 1, backgroundColor: '#E65100' }}>
<Main />
</SafeAreaView>
);
}
else {
SecureStore.setItemAsync('notFirstLaunch', "true");
return (
<Walkthrough />
);
}
};
我的 console.log 返回 value = true 但我的 if 语句永远不会只运行 else,请帮助!
【问题讨论】:
-
"true" 将被视为字符串。尝试删除引号。
-
它需要一个字符串作为键和值,取出引号会引发很多错误。
标签: react-native expo walkthrough