【发布时间】:2019-07-06 12:13:04
【问题描述】:
我正在开发一个项目,该项目在react-native 中有一个后端和多个前端应用程序。
我想在所有这些react-native 应用程序中使用一个主题来保持品牌/等重点。
有没有人找到办法做到这一点?
我尝试了从一个应用程序到另一个应用程序的 native-base-theme 文件夹的符号链接,但没有成功。
我正在为应用程序使用 Expo,在挖掘了一些问题线程后发现 Metro bundler 不遵循符号链接? https://github.com/facebook/react-native/issues/18725#issuecomment-380268250
我还尝试将 native-base-theme 文件夹移动到两个应用程序的父目录并以这种方式导入主题模块。
两种方式(符号链接和父目录)都给出了这些错误:
Unable to resolve module './native-base-theme/components' from '/Users/me/workspace/my-app/App.js'
The module './native-base-theme/components' could not be found from '/Users/me/workspace/my-app/App.js'
Indeed, none of these files exist:
'/Users/me/workspace/my-app/native-base-theme/components(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
'/Users/me/workspace/my-app/native-base-theme/components/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
/Users/me/workspace/my-app/native-base-theme/components/index.js 确实存在那里。
带符号链接:
import getTheme from './native-base-theme/components';
import platform from './native-base-theme/variables/platform';
与父目录:
import getTheme from '../native-base-theme/components';
import platform from '../native-base-theme/variables/platform';
也只是为了它而尝试:
import getTheme from '../native-base-theme/components/index';
和
import getTheme from '../native-base-theme/components/index.js';
import platform from '../native-base-theme/variables/platform.js';
根据文档,在使用 node node_modules/native-base/ejectTheme.js 弹出本机基础主题后,我正在导入相同的工作方式
我希望(希望?)为多个应用使用一个 native-base-theme 文件夹,以保持所有应用的主题一致。
【问题讨论】:
标签: react-native expo native-base