[如何通过使用Promise和本机AsyncStorage来更改应用程序主题? [重复]

问题描述 投票:0回答:1

我在我的本机项目中创建了2个主题,效果很好。

我只需要将lightMode更改为darkMode。

enter image description here要使用此主题,我只需要导入和使用:enter image description here

但是现在,我需要动态导入lightMode,我只能使用一个开关:

enter image description here

但是我如何使用asyncStorage做到这一点?因为我需要遵守承诺:

enter image description here

enter image description here

enter image description here

javascript react-native async-await asyncstorage
1个回答
0
投票

在这种情况下,

您需要在应用启动后立即将所有这些数据从存储(在这种情况下为AsyncStorage)加载到内存中。

您可以在显示初始屏幕时执行此操作。

© www.soinside.com 2019 - 2024. All rights reserved.