react-native - 在刷新之前,Mobx 状态不会在 App.js 中更新
问题描述
我在使用 Mobx 时遇到了一个小问题,其中状态到处都发生了很好的变化,但在 App.js 中却没有。我怎样才能实现它也直接在 App.js 中更新而无需刷新?
应用程序.js:
function App() {
const [rootStore, setRootStore] = useState<RootStore | undefined>(undefined)
(...)
// Kick off initial async loading actions, like loading fonts and RootStore
useEffect(() => {
;(async () => {
await initFonts() // expo
setupRootStore().then(setRootStore)
})()
}, [])
<ApplicationProvider {...eva} theme={rootStore.mode.dark ? eva.dark : eva.light}>
(...)
</ApplicationProvider>
}
解决方案
推荐阅读
- xaml - 如何访问 Xamarin.Forms 中以编程方式创建的 UI 元素:timepicker
- python - 将迭代图例添加到 python 函数
- flutter - 关闭应用程序后在 iOS 上的应用程序中打开 html 文件时随机呈现空白屏幕
- mysql - MySQL 语句跳过重复项
- scala - scala 如何在不实例化成员的情况下处理隐式类型类?
- awk - 从我的“猫”中排除单行,保留多行相似的行
- javascript - 使用 Linux/Windows CLI 命令行工具模拟 JavaScript 按钮单击(http 请求)
- simplesamlphp - 无法加载 InResponseTo 指定的状态:NOSTATE 将响应处理为未经请求
- python-3.x - 权限被拒绝安装 pyforest 笔记本扩展
- python - Python 官方最新版本、Homebrew 版本和安装版本在 macOS 上有所不同