This repo demonstrates Expo working in a Turbo Monorepo!
yarn workspace expo-app start
Turbo init:
npx create-turbo@latest turbo-expo
cd turbo-expo/apps
expo init expo-app
Choose the managed app with navigation
Expo automatically creates a .git
folder, which we need to remove:
rm -rf expo-app/.git
Modify packages/ui/Button.tsx to:
import { Button as RNButton } from "react-native";
export function Button({ onPress }: { onPress: () => void }) {
return <RNButton title="Boop" onPress={onPress} />;
}
https://docs.expo.dev/guides/monorepos/
- paste the metro.config.js
- package.json main set to
index.js
- paste the index.js
Add "ui": "*"
to dependencies of apps/expo-app/package.json
. (Then I think it is necessary to run yarn in repo root)
In apps/expo-app/components/EditScreenInfo.tsx
, add the button:
import { Button } from "ui";
<Button onPress={() => {}} />
React hook error: expo/expo#6287
Fixed by changing react to match minor version across all apps.
yarn workspace expo-app start
not specific to this repo, but this trick fixes cmd-r refresh in the simulator: https://twitter.com/jonstuebe/status/1390384513927184385
Basically change the keyboard shortcut for screen recording
Add to dependencies of apps/web/package.json
and apps/docs/package.json
:
"react-native-web": "^0.17.5",
From here: https://github.com/vercel/next.js/blob/master/examples/with-react-native-web/next.config.js
Set both next.config.js
files to:
const withTM = require("next-transpile-modules")(["ui"]);
module.exports = withTM({
reactStrictMode: true,
webpack: (config) => {
config.resolve.alias = {
...(config.resolve.alias || {}),
// Transform all direct `react-native` imports to `react-native-web`
"react-native$": "react-native-web",
};
config.resolve.extensions = [
".web.js",
".web.ts",
".web.tsx",
...config.resolve.extensions,
];
return config;
},
});
Start either Next app by running:
yarn workspace web dev
yarn workspace docs dev