|
| 1 | +# react-native-gesture-handler library |
| 2 | + |
| 3 | +## Project structure |
| 4 | + |
| 5 | +- This project has monorepo structure. |
| 6 | +- It contains both, library (`/packages/react-native-gesture-handler`) and documentation (/packages/docs-gesture-handler). |
| 7 | +- It is multiplatform. Library supports android, iOS, web and macos. |
| 8 | +- Android codebase is located in `/packages/react-native-gesture-handler/android` directory. iOS and macos in `/packages/react-native-gesture-handler/apple`. Web can be found in `/packages/react-native-gesture-handler/src/web`. |
| 9 | +- Some files are platform specific. Those have platform in the file extension, e.g. `RNGestureHandlerModule.web.ts` |
| 10 | + |
| 11 | +### Example apps |
| 12 | + |
| 13 | +- Example apps are located in `/apps` directory |
| 14 | +- `basic-example` is mostly used to check that android and iOS build correctly. |
| 15 | +- `expo-example` is used to test more advanced examples. Sources are located in `apps/common-app`. |
| 16 | +- `macos-example` is used to check if library works on macos. Sources are located in `apps/common-app`. |
| 17 | + |
| 18 | +### Packages |
| 19 | + |
| 20 | +- `/packages` contains documentation and main library package |
| 21 | +- This project contains 3 versions of API. The newest is located in `packages/react-native-gesture-handler/src/v3` directory. Most of the logic is shared, but make sure that your changes do not break older APIs. |
| 22 | +- When writing code, you can use `usesNativeOrVirtualDetector` function to either include only, or exclude new API v3. It is available on all platforms. |
| 23 | + |
| 24 | +## Build checks |
| 25 | + |
| 26 | +- To check Android build go to `apps/basic-example` and run `yarn android` command. |
| 27 | +- To check iOS build, go to `apps/basic-example` and run `yarn ios`. |
| 28 | +- To check macos build, go to `apps/macos-example` and run `yarn macos`. |
| 29 | +- After any build on macOS/Linux stop the Metro server with `for pid in $(lsof -ti :8081); do kill "$pid"; done` (this no-ops cleanly when nothing is listening on port 8081; `pkill -f "metro"` is not sufficient) |
| 30 | + |
| 31 | +## JavaScript checks |
| 32 | + |
| 33 | +- To run TypeScript checks use `yarn ts-check` command. You can run it directly in `packages/react-native-gesture-handler` if working on package, or from root of the repository. |
| 34 | +- To run Jest tests, use `yarn test` command in `packages/react-native-gesture-handler`. You can also pass filename to run tests from specific file. |
| 35 | +- To run eslint check, use `yarn lint:js` |
| 36 | + |
| 37 | +## Formatting |
| 38 | + |
| 39 | +- To format code use use `yarn format:{apple | android | js}`. `apple` works for both, iOS and macos. |
0 commit comments