情况:
正如您可能知道的那样,我目前正在构建一个有声读物播放器(多么有创意)。这是我第一个针对反应原生和打字稿的更大项目,在正确输入导航方面我有点挣扎。首先:这是一个快速概述:
疑问/问题:
// 1. I created a type for the Screen routes (including the passed down props)
type LibraryRoutes = {
Library: undefined;
BookDetails: { album: Album };
BookSettings: { album: Album };
};
// 2. A type for the different Routes (using NavigatorScreenParams, but I'm not sure I use them correctly)
// This then goes up the same way up to the root
type TabRoutes = {
HomeStack: NavigatorScreenParams<HomeRoutes>;
LibraryStack: NavigatorScreenParams<LibraryRoutes>;
...etc.
}; …Run Code Online (Sandbox Code Playgroud) typescript reactjs react-native typescript-typings react-navigation
在过去 1.5 天左右的时间里,我试图让 React-native-track-player 工作,但我就是无法实现它。无论我尝试什么,我总是会遇到相同的错误块:
\nERROR TypeError: null is not an object (evaluating \'TrackPlayer.RATING_HEART\')\nERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect. \n This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.\nRun Code Online (Sandbox Code Playgroud)\n我使用react-native expo和 “正常” react-native(根据react-native docu)设置它。对于我尝试过的所有变体:JSTS
我最近开始使用 RN,并一直在对主题和/或暗光模式的实现进行一些研究。到目前为止,我大致了解两个主要选项:
我不喜欢上下文的是(按照我的理解)它不允许我在使用样式表时访问主题,因为它位于组件之外。另一方面,对于样式化组件,我不确定是否可以覆盖自定义组件中的所有选项,是否仍然需要在每个组件中添加某种钩子?
我还在考虑将当前主题保存到我的商店(在我的例子中是 Zustand),以及一个让我切换到黑暗模式的操作。但到目前为止,我还没有看到其他人这样做,这样做有什么缺点吗?