我在设计 React Native Paper 样式时遇到了 React Native with Expo 的问题,我试图理解。
我针对该问题创建了一个代码示例:https://gitlab.com/mszymczakowski/react-native-paper-theming-issue
当我从 App.tsx
文件导出带有自定义主题的 const,然后导入并尝试在 HomeScreen.tsx
中使用它时,我收到类型错误 undefined is not an object (evaluating '_App.customTheme.colors')
。
将带有自定义主题的 const 移动到另一个 .ts
文件似乎可以解决这个问题 - 我可以在 App.tsx
和 HomeScreen.tsx
中使用它:https://gitlab.com/mszymczakowski/react-native-paper-theming-issue/-/tree/theme-fix
但正如我所提到的,我想了解这里发生了什么,以及为什么一种方法有错误,而第二种方法没有错误。
提前致谢