├── .nvmrc
├── .gitattributes
├── tsconfig.build.json
├── assets
└── demo.gif
├── .yarnrc.yml
├── example
├── tsconfig.json
├── babel.config.js
├── index.js
├── README.md
├── metro.config.js
├── app.json
├── package.json
└── src
│ └── App.tsx
├── babel.config.js
├── src
├── index.tsx
├── __tests__
│ └── index.test.tsx
├── types.tsx
├── createModalNavigator.tsx
└── ModalView.tsx
├── .editorconfig
├── lefthook.yml
├── .github
├── PULL_REQUEST_TEMPLATE.md
├── workflows
│ ├── versions.yml
│ ├── expo.yml
│ ├── expo-preview.yml
│ ├── ci.yml
│ ├── release.yml
│ └── triage.yml
├── actions
│ └── setup
│ │ └── action.yml
└── ISSUE_TEMPLATE
│ └── bug_report.md
├── eslint.config.mjs
├── tsconfig.json
├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── package.json
├── README.md
└── CONTRIBUTING.md
/.nvmrc:
--------------------------------------------------------------------------------
1 | v22.18.0
2 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pbxproj -text
2 | # specific for windows script files
3 | *.bat text eol=crlf
--------------------------------------------------------------------------------
/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig",
3 | "exclude": ["example"]
4 | }
5 |
--------------------------------------------------------------------------------
/assets/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/satya164/react-navigation-native-modal/HEAD/assets/demo.gif
--------------------------------------------------------------------------------
/.yarnrc.yml:
--------------------------------------------------------------------------------
1 | nmHoistingLimits: workspaces
2 |
3 | nodeLinker: node-modules
4 |
5 | yarnPath: .yarn/releases/yarn-4.9.2.cjs
6 |
--------------------------------------------------------------------------------
/example/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig",
3 | "compilerOptions": {
4 | // Avoid expo-cli auto-generating a tsconfig
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | overrides: [
3 | {
4 | exclude: /\/node_modules\//,
5 | presets: ['module:react-native-builder-bob/babel-preset'],
6 | },
7 | {
8 | include: /\/node_modules\//,
9 | presets: ['module:@react-native/babel-preset'],
10 | },
11 | ],
12 | };
13 |
--------------------------------------------------------------------------------
/example/babel.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const { getConfig } = require('react-native-builder-bob/babel-config');
3 | const pkg = require('../package.json');
4 |
5 | const root = path.resolve(__dirname, '..');
6 |
7 | module.exports = getConfig(
8 | {
9 | presets: ['babel-preset-expo'],
10 | },
11 | { root, pkg }
12 | );
13 |
--------------------------------------------------------------------------------
/src/index.tsx:
--------------------------------------------------------------------------------
1 | /**
2 | * Navigators
3 | */
4 | export { createModalNavigator } from './createModalNavigator';
5 |
6 | /**
7 | * Views
8 | */
9 | export { ModalView } from './ModalView';
10 |
11 | /**
12 | * Types
13 | */
14 | export type {
15 | ModalNavigationOptions,
16 | ModalNavigationProp,
17 | ModalScreenProps,
18 | } from './types';
19 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent
2 | # coding styles between different editors and IDEs
3 | # editorconfig.org
4 |
5 | root = true
6 |
7 | [*]
8 |
9 | indent_style = space
10 | indent_size = 2
11 |
12 | end_of_line = lf
13 | charset = utf-8
14 | trim_trailing_whitespace = true
15 | insert_final_newline = true
16 |
--------------------------------------------------------------------------------
/example/index.js:
--------------------------------------------------------------------------------
1 | import { registerRootComponent } from 'expo';
2 |
3 | import { App } from './src/App.tsx';
4 |
5 | // registerRootComponent calls AppRegistry.registerComponent('main', () => App);
6 | // It also ensures that whether you load the app in the Expo client or in a native build,
7 | // the environment is set up appropriately
8 | registerRootComponent(App);
9 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # Run the example
2 |
3 | - [View it with Expo](https://expo.dev/%40satya164/react-navigation-native-modal-example?serviceType=eas&distribution=expo-go&scheme=&channel=&sdkVersion=)
4 | - Run the example locally
5 | - Clone the repository and run `yarn` to install the dependencies
6 | - Run `yarn example start` to start the packager
7 | - Scan the QR Code with the Expo app
8 |
--------------------------------------------------------------------------------
/lefthook.yml:
--------------------------------------------------------------------------------
1 | pre-commit:
2 | parallel: true
3 | commands:
4 | lint:
5 | glob: "*.{js,ts,tsx}"
6 | run: yarn eslint {staged_files}
7 | types:
8 | glob: "*.{json,js,ts,tsx}"
9 | run: yarn tsc --noEmit
10 | test:
11 | glob: "*.{json,js,ts,tsx}"
12 | run: yarn test
13 | commit-msg:
14 | parallel: true
15 | commands:
16 | commitlint:
17 | run: npx commitlint --edit
18 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ### Motivation
5 |
6 |
7 |
8 | ### Test plan
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.github/workflows/versions.yml:
--------------------------------------------------------------------------------
1 | name: Check versions
2 | on:
3 | issues:
4 | types: [opened]
5 |
6 | jobs:
7 | check-versions:
8 | runs-on: ubuntu-latest
9 | steps:
10 | - uses: react-navigation/check-versions-action@v1.0.0
11 | with:
12 | github-token: ${{ secrets.GITHUB_TOKEN }}
13 | required-packages: |
14 | react-native
15 | react-navigation-native-modal
16 | optional-packages: |
17 | expo
18 |
--------------------------------------------------------------------------------
/eslint.config.mjs:
--------------------------------------------------------------------------------
1 | import { defineConfig, globalIgnores } from 'eslint/config';
2 | import { jest, react, recommended } from 'eslint-config-satya164';
3 | import sort from 'eslint-plugin-simple-import-sort';
4 |
5 | export default defineConfig([
6 | recommended,
7 | react,
8 | jest,
9 |
10 | globalIgnores([
11 | '**/node_modules/',
12 | '**/coverage/',
13 | '**/dist/',
14 | '**/lib/',
15 | '**/.expo/',
16 | '**/.yarn/',
17 | '**/.vscode/',
18 | ]),
19 |
20 | {
21 | plugins: {
22 | 'simple-import-sort': sort,
23 | },
24 | },
25 | ]);
26 |
--------------------------------------------------------------------------------
/example/metro.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const { getDefaultConfig } = require('@expo/metro-config');
3 | const { withMetroConfig } = require('react-native-monorepo-config');
4 |
5 | const root = path.resolve(__dirname, '..');
6 |
7 | /**
8 | * Metro configuration
9 | * https://facebook.github.io/metro/docs/configuration
10 | *
11 | * @type {import('metro-config').MetroConfig}
12 | */
13 | const config = withMetroConfig(getDefaultConfig(__dirname), {
14 | root,
15 | dirname: __dirname,
16 | });
17 |
18 | config.resolver.unstable_enablePackageExports = true;
19 |
20 | module.exports = config;
21 |
--------------------------------------------------------------------------------
/example/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "expo": {
3 | "name": "react-navigation-native-modal-example",
4 | "slug": "react-navigation-native-modal-example",
5 | "description": "Example app for react-navigation-native-modal",
6 | "version": "1.0.0",
7 | "platforms": [
8 | "ios",
9 | "android",
10 | "web"
11 | ],
12 | "ios": {
13 | "supportsTablet": true
14 | },
15 | "assetBundlePatterns": [
16 | "**/*"
17 | ],
18 | "extra": {
19 | "eas": {
20 | "projectId": "fa39f722-fcc0-423d-ada0-7fd5901c5b71"
21 | }
22 | },
23 | "owner": "satya164"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/.github/workflows/expo.yml:
--------------------------------------------------------------------------------
1 | name: Expo Publish
2 | on:
3 | push:
4 | branches:
5 | - main
6 | workflow_dispatch:
7 |
8 | jobs:
9 | publish:
10 | name: Install and publish
11 | runs-on: ubuntu-latest
12 | steps:
13 | - name: Checkout
14 | uses: actions/checkout@v5
15 |
16 | - name: Setup
17 | uses: ./.github/actions/setup
18 |
19 | - name: Setup Expo
20 | uses: expo/expo-github-action@v8
21 | with:
22 | eas-version: latest
23 | token: ${{ secrets.EXPO_TOKEN }}
24 |
25 | - name: Publish Expo app
26 | working-directory: ./example
27 | run: eas update --non-interactive --auto
28 |
--------------------------------------------------------------------------------
/.github/workflows/expo-preview.yml:
--------------------------------------------------------------------------------
1 | name: Expo Preview
2 | on:
3 | pull_request:
4 |
5 | jobs:
6 | publish:
7 | name: Install and publish
8 | runs-on: ubuntu-latest
9 | if: github.event.pull_request.head.repo.owner.login == 'satya164'
10 | steps:
11 | - name: Checkout
12 | uses: actions/checkout@v5
13 |
14 | - name: Setup
15 | uses: ./.github/actions/setup
16 |
17 | - name: Setup Expo
18 | uses: expo/expo-github-action@v8
19 | with:
20 | eas-version: latest
21 | token: ${{ secrets.EXPO_TOKEN }}
22 |
23 | - name: Comment preview
24 | uses: expo/expo-github-action/preview@v8
25 | with:
26 | working-directory: ./example
27 | command: eas update --non-interactive --auto
28 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "rootDir": ".",
4 | "paths": {
5 | "react-navigation-native-modal": ["./src/index.tsx"]
6 | },
7 | "allowUnreachableCode": false,
8 | "allowUnusedLabels": false,
9 | "esModuleInterop": true,
10 | "forceConsistentCasingInFileNames": true,
11 | "jsx": "react",
12 | "lib": ["esnext"],
13 | "module": "esnext",
14 | "moduleResolution": "node",
15 | "noFallthroughCasesInSwitch": true,
16 | "noImplicitReturns": true,
17 | "noImplicitUseStrict": false,
18 | "noStrictGenericChecks": false,
19 | "noUncheckedIndexedAccess": true,
20 | "noUnusedLocals": true,
21 | "noUnusedParameters": true,
22 | "resolveJsonModule": true,
23 | "skipLibCheck": true,
24 | "strict": true,
25 | "target": "esnext",
26 | "verbatimModuleSyntax": true
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/.github/actions/setup/action.yml:
--------------------------------------------------------------------------------
1 | name: Setup
2 | description: Setup Node.js and install dependencies
3 |
4 | runs:
5 | using: composite
6 | steps:
7 | - name: Setup Node.js
8 | uses: actions/setup-node@v3
9 | with:
10 | node-version-file: .nvmrc
11 |
12 | - name: Cache dependencies
13 | id: yarn-cache
14 | uses: actions/cache@v4
15 | with:
16 | path: |
17 | **/node_modules
18 | .yarn/install-state.gz
19 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }}
20 | restore-keys: |
21 | ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
22 | ${{ runner.os }}-yarn-
23 |
24 | - name: Install dependencies
25 | if: steps.yarn-cache.outputs.cache-hit != 'true'
26 | run: yarn install --immutable
27 | shell: bash
28 |
--------------------------------------------------------------------------------
/example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-navigation-native-modal-example",
3 | "description": "Example app for react-navigation-native-modal",
4 | "version": "0.0.1",
5 | "private": true,
6 | "main": "index",
7 | "scripts": {
8 | "android": "expo start --android",
9 | "ios": "expo start --ios",
10 | "start": "expo start",
11 | "test": "jest"
12 | },
13 | "dependencies": {
14 | "@react-navigation/native": "^7.1.17",
15 | "expo": "^53.0.20",
16 | "react": "19.0.0",
17 | "react-native": "0.79.5",
18 | "react-navigation-native-modal": "workspace:^"
19 | },
20 | "devDependencies": {
21 | "@babel/core": "^7.28.0",
22 | "@babel/runtime": "^7.28.2",
23 | "@expo/metro-config": "^0.20.17",
24 | "babel-preset-expo": "~13.0.0",
25 | "react-native-builder-bob": "^0.40.13",
26 | "react-native-monorepo-config": "^0.1.9"
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # XDE
6 | .expo/
7 |
8 | # VSCode
9 | .vscode/
10 | jsconfig.json
11 |
12 | # Xcode
13 | #
14 | build/
15 | *.pbxuser
16 | !default.pbxuser
17 | *.mode1v3
18 | !default.mode1v3
19 | *.mode2v3
20 | !default.mode2v3
21 | *.perspectivev3
22 | !default.perspectivev3
23 | xcuserdata
24 | *.xccheckout
25 | *.moved-aside
26 | DerivedData
27 | *.hmap
28 | *.ipa
29 | *.xcuserstate
30 | project.xcworkspace
31 |
32 | # Android/IJ
33 | #
34 | .idea
35 | .gradle
36 | local.properties
37 | android.iml
38 |
39 | # Cocoapods
40 | #
41 | example/ios/Pods
42 |
43 | # node.js
44 | #
45 | node_modules/
46 | npm-debug.log
47 | yarn-debug.log
48 | yarn-error.log
49 |
50 | # BUCK
51 | buck-out/
52 | \.buckd/
53 | android/app/libs
54 | android/keystores/debug.keystore
55 |
56 | # Expo
57 | .expo/*
58 |
59 | # Yarn
60 | .yarn/*
61 | !.yarn/patches
62 | !.yarn/plugins
63 | !.yarn/releases
64 | !.yarn/sdks
65 | !.yarn/versions
66 |
67 | # generated by bob
68 | lib/
69 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## 0.3.1 (2025-08-13)
4 |
5 | * ci: update release workflow ([5a0de06](https://github.com/satya164/react-navigation-native-modal/commit/5a0de06))
6 | * docs: document static config api ([ade7995](https://github.com/satya164/react-navigation-native-modal/commit/ade7995))
7 |
8 | ## 0.3.0 (2025-08-13)
9 |
10 | * feat: upgrade to react nvigation 7 ([87f4a54](https://github.com/satya164/react-navigation-native-modal/commit/87f4a54))
11 |
12 | ## [0.1.11](https://github.com/satya164/react-navigation-native-modal/compare/v0.1.10...v0.1.11) (2023-11-02)
13 |
14 | ## [0.1.10](https://github.com/satya164/react-navigation-native-modal/compare/v0.1.9...v0.1.10) (2023-11-02)
15 |
16 | ## [0.1.9](https://github.com/satya164/react-navigation-native-modal/compare/v0.1.6...v0.1.9) (2023-11-02)
17 |
18 |
19 | ### Bug Fixes
20 |
21 | * upgrade to use react navigation 6 ([aba8c58](https://github.com/satya164/react-navigation-native-modal/commit/aba8c58305ae405eb9b8686c9e32d453f713f1a2))
22 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on:
3 | push:
4 | branches:
5 | - main
6 | pull_request:
7 | branches:
8 | - main
9 |
10 | jobs:
11 | lint:
12 | runs-on: ubuntu-latest
13 | steps:
14 | - name: Checkout
15 | uses: actions/checkout@v5
16 |
17 | - name: Setup
18 | uses: ./.github/actions/setup
19 |
20 | - name: Lint files
21 | run: yarn lint
22 |
23 | - name: Typecheck files
24 | run: yarn typecheck
25 |
26 | test:
27 | runs-on: ubuntu-latest
28 | steps:
29 | - name: Checkout
30 | uses: actions/checkout@v5
31 |
32 | - name: Setup
33 | uses: ./.github/actions/setup
34 |
35 | - name: Run unit tests
36 | run: yarn test --maxWorkers=2 --coverage
37 |
38 | build-library:
39 | runs-on: ubuntu-latest
40 | steps:
41 | - name: Checkout
42 | uses: actions/checkout@v5
43 |
44 | - name: Setup
45 | uses: ./.github/actions/setup
46 |
47 | - name: Build package
48 | run: yarn prepare
49 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Satyajit Sahoo
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/__tests__/index.test.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { View, Text, Button } from 'react-native';
3 | import { render } from '@testing-library/react-native';
4 | import {
5 | NavigationContainer,
6 | type ParamListBase,
7 | } from '@react-navigation/native';
8 | import { createModalNavigator, type ModalScreenProps } from '../index';
9 |
10 | jest.useFakeTimers();
11 | test('renders a modal navigator with screens', async () => {
12 | const Test = ({ route, navigation }: ModalScreenProps) => (
13 |
14 | Screen {route.name}
15 |
18 | );
19 |
20 | const Modal = createModalNavigator();
21 |
22 | const { queryByText } = render(
23 |
24 |
25 |
26 |
27 |
28 |
29 | );
30 |
31 | expect(queryByText('Screen A')).not.toBeNull();
32 | expect(queryByText('Screen B')).toBeNull();
33 | });
34 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Please search the existing issues and read the documentation before opening
4 | an issue.
5 | title: ''
6 | labels: bug
7 | assignees: ''
8 |
9 | ---
10 |
11 |
12 |
13 | ### Current behaviour
14 |
15 |
16 |
17 | ### Expected behaviour
18 |
19 |
20 |
21 | ### Code sample
22 |
23 | For Syntax Highlighting check this [link](https://help.github.com/en/articles/creating-and-highlighting-code-blocks)
24 |
25 |
26 |
27 | ### Screenshots (if applicable)
28 |
29 |
30 |
31 | ### What have you tried
32 |
33 |
34 |
35 | ### Your Environment
36 |
37 | | software | version
38 | | ----------------------------- | -------
39 | | ios or android |
40 | | expo |
41 | | react-native |
42 | | react-navigation-native-modal |
43 | | node |
44 | | npm or yarn |
45 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release package
2 | on:
3 | workflow_run:
4 | branches:
5 | - main
6 | workflows:
7 | - CI
8 | types:
9 | - completed
10 |
11 | jobs:
12 | check-commit:
13 | runs-on: ubuntu-latest
14 | if: ${{ github.event.workflow_run.conclusion == 'success' }}
15 | outputs:
16 | skip: ${{ steps.commit-message.outputs.skip }}
17 | steps:
18 | - name: Checkout
19 | uses: actions/checkout@v5
20 |
21 | - name: Get commit message
22 | id: commit-message
23 | run: |
24 | MESSAGE=$(git log --format=%B -n 1 $(git log -1 --pretty=format:"%h"))
25 |
26 | if [[ $MESSAGE == "chore: release "* ]]; then
27 | echo "skip=true" >> $GITHUB_OUTPUT
28 | fi
29 |
30 | release:
31 | runs-on: ubuntu-latest
32 | permissions:
33 | contents: read
34 | id-token: write
35 | needs: check-commit
36 | if: ${{ needs.check-commit.outputs.skip != 'true' }}
37 | steps:
38 | - name: Checkout
39 | uses: actions/checkout@v5
40 | with:
41 | fetch-depth: 0
42 | token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
43 |
44 | - name: Setup
45 | uses: ./.github/actions/setup
46 |
47 | - name: Configure Git
48 | run: |
49 | git config user.name "${GITHUB_ACTOR}"
50 | git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
51 |
52 | - name: Create release
53 | run: |
54 | npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
55 | yarn release-it --ci
56 | env:
57 | GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
58 | NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
59 | NPM_CONFIG_PROVENANCE: true
60 |
--------------------------------------------------------------------------------
/.github/workflows/triage.yml:
--------------------------------------------------------------------------------
1 | name: Triage
2 | on:
3 | issues:
4 | types: [labeled]
5 |
6 | jobs:
7 | needs-more-info:
8 | runs-on: ubuntu-latest
9 | if: github.event.label.name == 'needs more info'
10 | steps:
11 | - uses: actions/github-script@v2
12 | with:
13 | github-token: ${{secrets.GITHUB_TOKEN}}
14 | script: |
15 | github.issues.createComment({
16 | issue_number: context.issue.number,
17 | owner: context.repo.owner,
18 | repo: context.repo.repo,
19 | body: "Hey! Thanks for opening the issue. Can you provide more information about the issue? Please fill the issue template when opening the issue without deleting any section. We need all the information we can to be able to help.\n\nMake sure to at least provide - Current behaviour, Expected behaviour, A way to [reproduce the issue with minimal code](https://stackoverflow.com/help/minimal-reproducible-example) (link to [snack.expo.io](https://snack.expo.io)) or a repo on GitHub, and the information about your environment (such as the platform of the device, exact versions of all the packages mentioned in the template etc.)."
20 | })
21 |
22 | needs-repro:
23 | runs-on: ubuntu-latest
24 | if: github.event.label.name == 'needs repro'
25 | steps:
26 | - uses: actions/github-script@v2
27 | with:
28 | github-token: ${{secrets.GITHUB_TOKEN}}
29 | script: |
30 | github.issues.createComment({
31 | issue_number: context.issue.number,
32 | owner: context.repo.owner,
33 | repo: context.repo.repo,
34 | body: "Hey! Thanks for opening the issue. Can you provide a [minimal repro](https://stackoverflow.com/help/minimal-reproducible-example) which demonstrates the issue? Posting a snippet of your code in the issue is useful, but it's not usually straightforward to run. A repro will help us debug the issue faster. Please try to keep the repro as small as possible.\n\nThe easiest way to provide a repro is on [snack.expo.io](https://snack.expo.io). If it's not possible to repro it on [snack.expo.io](https://snack.expo.io), then please provide the repro in a GitHub repository."
35 | })
36 |
--------------------------------------------------------------------------------
/src/types.tsx:
--------------------------------------------------------------------------------
1 | import type { Modal } from 'react-native';
2 | import type {
3 | Route,
4 | ParamListBase,
5 | NavigationProp,
6 | Descriptor,
7 | NavigationHelpers,
8 | RouteProp,
9 | StackNavigationState,
10 | StackActionHelpers,
11 | } from '@react-navigation/native';
12 |
13 | export type Scene = {
14 | route: Route;
15 | focused: boolean;
16 | color?: string;
17 | };
18 |
19 | // eslint-disable-next-line @typescript-eslint/no-empty-object-type
20 | export type ModalNavigationConfig = {};
21 |
22 | export type ModalNavigationOptions = Omit<
23 | React.ComponentProps,
24 | 'visible' | 'onDismiss' | 'onOrientationChange' | 'onRequestClose' | 'onShow'
25 | >;
26 |
27 | export type ModalNavigationEventMap = {
28 | /**
29 | * Event which fires when the orientation changes while the modal is being displayed.
30 | * The orientation provided is only 'portrait' or 'landscape'.
31 | * This event also fires on initial render, regardless of the current orientation.
32 | * Only supported on iOS.
33 | */
34 | orientationChange: { data: { orientation: 'portrait' | 'landscape' } };
35 | };
36 |
37 | export type ModalNavigationHelpers = NavigationHelpers<
38 | ParamListBase,
39 | ModalNavigationEventMap
40 | > &
41 | StackActionHelpers;
42 |
43 | export type ModalNavigationProp<
44 | ParamList extends ParamListBase,
45 | RouteName extends keyof ParamList = keyof ParamList,
46 | NavigatorID extends string | undefined = undefined,
47 | > = NavigationProp<
48 | ParamList,
49 | RouteName,
50 | NavigatorID,
51 | StackNavigationState,
52 | ModalNavigationOptions,
53 | ModalNavigationEventMap
54 | > &
55 | StackActionHelpers;
56 |
57 | export type ModalScreenProps<
58 | ParamList extends ParamListBase,
59 | RouteName extends keyof ParamList = keyof ParamList,
60 | NavigatorID extends string | undefined = undefined,
61 | > = {
62 | navigation: ModalNavigationProp;
63 | route: RouteProp;
64 | };
65 |
66 | export type ModalDescriptor = Descriptor<
67 | ModalNavigationOptions,
68 | ModalNavigationProp,
69 | RouteProp
70 | >;
71 |
72 | export type ModalDescriptorMap = {
73 | [key: string]: ModalDescriptor;
74 | };
75 |
--------------------------------------------------------------------------------
/example/src/App.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { StyleSheet, View, Button } from 'react-native';
3 | import {
4 | createStaticNavigation,
5 | useNavigation,
6 | type StaticParamList,
7 | } from '@react-navigation/native';
8 | import {
9 | createModalNavigator,
10 | type ModalNavigationProp,
11 | } from 'react-navigation-native-modal';
12 |
13 | function Home() {
14 | const navigation = useNavigation();
15 |
16 | return (
17 |
18 | navigation.navigate('First')}
21 | />
22 | navigation.navigate('Second')}
25 | />
26 |
27 | );
28 | }
29 |
30 | function First() {
31 | const navigation = useNavigation>();
32 |
33 | return (
34 |
35 | navigation.navigate('Second')}
38 | />
39 | navigation.goBack()} />
40 | navigation.popToTop()} />
41 |
42 | );
43 | }
44 |
45 | function Second() {
46 | const navigation = useNavigation>();
47 |
48 | return (
49 |
50 | navigation.navigate('First')}
53 | />
54 | navigation.goBack()} />
55 | navigation.popToTop()} />
56 |
57 | );
58 | }
59 |
60 | const Modal = createModalNavigator({
61 | screens: {
62 | Home: {
63 | screen: Home,
64 | },
65 | First: {
66 | screen: First,
67 | },
68 | Second: {
69 | screen: Second,
70 | options: {
71 | presentationStyle: 'pageSheet',
72 | },
73 | },
74 | },
75 | });
76 |
77 | const Navigation = createStaticNavigation(Modal);
78 |
79 | export function App() {
80 | return ;
81 | }
82 |
83 | const styles = StyleSheet.create({
84 | container: {
85 | flex: 1,
86 | alignItems: 'center',
87 | justifyContent: 'center',
88 | },
89 | });
90 |
91 | type RootStackParamList = StaticParamList;
92 |
93 | declare global {
94 | // eslint-disable-next-line @typescript-eslint/no-namespace
95 | namespace ReactNavigation {
96 | // eslint-disable-next-line @typescript-eslint/no-empty-object-type
97 | interface RootParamList extends RootStackParamList {}
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/src/createModalNavigator.tsx:
--------------------------------------------------------------------------------
1 | import {
2 | StackRouter,
3 | createNavigatorFactory,
4 | useNavigationBuilder,
5 | type DefaultNavigatorOptions,
6 | type NavigationProp,
7 | type NavigatorTypeBagBase,
8 | type ParamListBase,
9 | type StackActionHelpers,
10 | type StackNavigationState,
11 | type StackRouterOptions,
12 | type StaticConfig,
13 | type TypedNavigator,
14 | } from '@react-navigation/native';
15 | import * as React from 'react';
16 | import { ModalView } from './ModalView';
17 | import type {
18 | ModalNavigationConfig,
19 | ModalNavigationEventMap,
20 | ModalNavigationOptions,
21 | } from './types';
22 |
23 | type ModalNavigationProp<
24 | ParamList extends ParamListBase,
25 | RouteName extends keyof ParamList = keyof ParamList,
26 | NavigatorID extends string | undefined = undefined,
27 | > = NavigationProp<
28 | ParamList,
29 | RouteName,
30 | NavigatorID,
31 | StackNavigationState,
32 | ModalNavigationOptions,
33 | ModalNavigationEventMap
34 | > &
35 | StackActionHelpers;
36 |
37 | type Props = DefaultNavigatorOptions<
38 | ParamListBase,
39 | string | undefined,
40 | StackNavigationState,
41 | ModalNavigationOptions,
42 | ModalNavigationEventMap,
43 | ModalNavigationProp
44 | > &
45 | StackRouterOptions &
46 | ModalNavigationConfig;
47 |
48 | function ModalNavigator({
49 | id,
50 | initialRouteName,
51 | children,
52 | layout,
53 | screenLayout,
54 | screenOptions,
55 | screenListeners,
56 | UNSTABLE_router,
57 | ...rest
58 | }: Props) {
59 | const { state, descriptors, navigation, NavigationContent } =
60 | useNavigationBuilder<
61 | StackNavigationState,
62 | StackRouterOptions,
63 | StackActionHelpers,
64 | ModalNavigationOptions,
65 | ModalNavigationEventMap
66 | >(StackRouter, {
67 | id,
68 | initialRouteName,
69 | children,
70 | layout,
71 | screenLayout,
72 | screenOptions,
73 | screenListeners,
74 | UNSTABLE_router,
75 | });
76 |
77 | return (
78 |
79 |
85 |
86 | );
87 | }
88 |
89 | export function createModalNavigator<
90 | const ParamList extends ParamListBase,
91 | const NavigatorID extends string | undefined = undefined,
92 | const TypeBag extends NavigatorTypeBagBase = {
93 | ParamList: ParamList;
94 | NavigatorID: NavigatorID;
95 | State: StackNavigationState;
96 | ScreenOptions: ModalNavigationOptions;
97 | EventMap: ModalNavigationEventMap;
98 | NavigationList: {
99 | [RouteName in keyof ParamList]: ModalNavigationProp<
100 | ParamList,
101 | RouteName,
102 | NavigatorID
103 | >;
104 | };
105 | Navigator: typeof ModalNavigator;
106 | },
107 | const Config extends StaticConfig = StaticConfig,
108 | >(config?: Config): TypedNavigator {
109 | return createNavigatorFactory(ModalNavigator)(config);
110 | }
111 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-navigation-native-modal",
3 | "version": "0.3.1",
4 | "description": "React Navigation integration for React Native's Modal component",
5 | "main": "lib/commonjs/index.js",
6 | "module": "lib/module/index.js",
7 | "types": "lib/typescript/src/index.d.ts",
8 | "react-native": "src/index.tsx",
9 | "source": "src/index.tsx",
10 | "files": [
11 | "src",
12 | "lib",
13 | "!**/__tests__",
14 | "!**/__fixtures__",
15 | "!**/__mocks__",
16 | "android",
17 | "ios",
18 | "cpp",
19 | "react-navigation-native-modal.podspec",
20 | "!lib/typescript/example"
21 | ],
22 | "workspaces": [
23 | "example"
24 | ],
25 | "scripts": {
26 | "test": "jest",
27 | "typecheck": "tsc --noEmit",
28 | "lint": "eslint \"**/*.{js,ts,tsx}\"",
29 | "prepare": "bob build",
30 | "release": "release-it --only-version",
31 | "example": "yarn workspace react-navigation-native-modal-example"
32 | },
33 | "keywords": [
34 | "react-native",
35 | "react-navigation",
36 | "ios",
37 | "android",
38 | "expo",
39 | "modal"
40 | ],
41 | "repository": "https://github.com/satya164/react-navigation-native-modal",
42 | "author": "Satyajit Sahoo (https://github.com/satya164)",
43 | "license": "MIT",
44 | "bugs": {
45 | "url": "https://github.com/satya164/react-navigation-native-modal/issues"
46 | },
47 | "homepage": "https://github.com/satya164/react-navigation-native-modal#readme",
48 | "publishConfig": {
49 | "registry": "https://registry.npmjs.org/"
50 | },
51 | "devDependencies": {
52 | "@commitlint/config-conventional": "^19.8.1",
53 | "@evilmartians/lefthook": "^1.5.2",
54 | "@react-native/babel-preset": "^0.81.0",
55 | "@react-navigation/native": "^7.1.17",
56 | "@release-it/conventional-changelog": "^10.0.1",
57 | "@testing-library/react-native": "^13.2.2",
58 | "@types/jest": "^30.0.0",
59 | "@types/react": "^19.1.10",
60 | "@types/react-native": "0.73.0",
61 | "commitlint": "^19.8.1",
62 | "eslint": "^9.33.0",
63 | "eslint-config-satya164": "^5.1.3",
64 | "eslint-plugin-simple-import-sort": "^12.1.1",
65 | "jest": "^30.0.5",
66 | "prettier": "^3.6.2",
67 | "react": "19.0.0",
68 | "react-native": "0.79.5",
69 | "react-native-builder-bob": "^0.40.13",
70 | "react-test-renderer": "19.0.0",
71 | "release-it": "^19.0.4",
72 | "typescript": "^5.9.2"
73 | },
74 | "peerDependencies": {
75 | "@react-navigation/native": "^7.0.0",
76 | "react": ">= 19.0.0",
77 | "react-native": "*"
78 | },
79 | "packageManager": "yarn@4.9.2",
80 | "jest": {
81 | "preset": "react-native",
82 | "modulePathIgnorePatterns": [
83 | "/lib/"
84 | ],
85 | "transformIgnorePatterns": [
86 | "node_modules/(?!((jest-)?@react-native|react-native|@react-navigation)/)"
87 | ]
88 | },
89 | "commitlint": {
90 | "extends": [
91 | "@commitlint/config-conventional"
92 | ]
93 | },
94 | "release-it": {
95 | "git": {
96 | "commitMessage": "chore: release ${version}",
97 | "tagName": "v${version}"
98 | },
99 | "npm": {
100 | "publish": true
101 | },
102 | "github": {
103 | "release": true
104 | },
105 | "plugins": {
106 | "@release-it/conventional-changelog": {
107 | "preset": {
108 | "name": "conventionalcommits"
109 | },
110 | "infile": "CHANGELOG.md"
111 | }
112 | }
113 | },
114 | "prettier": {
115 | "quoteProps": "consistent",
116 | "singleQuote": true,
117 | "tabWidth": 2,
118 | "trailingComma": "es5",
119 | "useTabs": false
120 | },
121 | "react-native-builder-bob": {
122 | "source": "src",
123 | "output": "lib",
124 | "targets": [
125 | "commonjs",
126 | "module",
127 | "typescript"
128 | ]
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/src/ModalView.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import {
3 | View,
4 | Modal,
5 | StyleSheet,
6 | type NativeSyntheticEvent,
7 | } from 'react-native';
8 | import {
9 | NavigationHelpersContext,
10 | type StackNavigationState,
11 | type ParamListBase,
12 | StackActions,
13 | CommonActions,
14 | } from '@react-navigation/native';
15 | import type {
16 | ModalDescriptorMap,
17 | ModalNavigationConfig,
18 | ModalNavigationHelpers,
19 | } from './types';
20 |
21 | type Props = ModalNavigationConfig & {
22 | state: StackNavigationState;
23 | navigation: ModalNavigationHelpers;
24 | descriptors: ModalDescriptorMap;
25 | };
26 |
27 | export function ModalView({ state, navigation, descriptors }: Props) {
28 | return (
29 |
30 |
31 | {state.routes.reduceRight(
32 | (acc, route, index) => {
33 | const focused = index === state.index;
34 | const descriptor = descriptors[route.key];
35 |
36 | if (descriptor == null) {
37 | return acc;
38 | }
39 |
40 | const { animationType = 'slide', ...options } = descriptor.options;
41 |
42 | const element = (
43 | <>
44 |
51 | {descriptor.render()}
52 |
53 | {acc}
54 | >
55 | );
56 |
57 | if (index === 0) {
58 | return element;
59 | }
60 |
61 | const onOrientationChange = (
62 | e: NativeSyntheticEvent<{ orientation: 'portrait' | 'landscape' }>
63 | ) =>
64 | navigation.emit({
65 | type: 'orientationChange',
66 | target: route.key,
67 | data: e.nativeEvent,
68 | });
69 |
70 | const onOpen = () => {
71 | navigation.dispatch((s) => {
72 | if (
73 | s.routeNames.includes(route.name) &&
74 | !s.routes.some((r) => r.key === route.key)
75 | ) {
76 | // If route isn't present in current state, but was closing, assume that a close animation was cancelled
77 | // So we need to add this route back to the state
78 | return CommonActions.navigate(route);
79 | } else {
80 | return CommonActions.reset(s);
81 | }
82 | });
83 | };
84 |
85 | const onClose = () =>
86 | navigation.dispatch((s) => {
87 | // If a route exists in state, trigger a pop
88 | // This will happen in when the route was closed from native side
89 | // e.g. When the close animation triggered from a gesture ends
90 | if (s.routes.some((r) => r.key === route.key)) {
91 | return {
92 | ...StackActions.pop(),
93 | source: route.key,
94 | target: s.key,
95 | };
96 | } else {
97 | return CommonActions.reset(s);
98 | }
99 | });
100 |
101 | return (
102 |
111 | {element}
112 |
113 | );
114 | },
115 | <>>
116 | )}
117 |
118 |
119 | );
120 | }
121 |
122 | const styles = StyleSheet.create({
123 | container: {
124 | flex: 1,
125 | },
126 | });
127 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-navigation-native-modal
2 |
3 | [![Build Status][build-badge]][build]
4 | [![Version][version-badge]][package]
5 | [![MIT License][license-badge]][license]
6 |
7 | React Navigation integration for React Native's Modal component. This navigator works like a Stack Navigator, but each screen is shown as a modal using the `Modal` component from React Native.
8 |
9 | > Currently the `presentationStyle` of `pageSheet` and `formSheet` are not usable on iOS because it's impossible to detect when they are closed via gesture. See
10 |
11 | ## Demo
12 |
13 |
14 |
15 | ## Installation
16 |
17 | ```sh
18 | npm install @react-navigation/native react-navigation-native-modal
19 | ```
20 |
21 | ## Usage
22 |
23 | To use this navigator, import it from `react-navigation-native-modal`:
24 |
25 | With static config API:
26 |
27 | ```js
28 | import { createModalNavigator } from 'react-navigation-native-modal';
29 |
30 | const MyModal = createModalNavigator({
31 | screens: {
32 | Home: {
33 | screen: HomeScreen,
34 | },
35 | Profile: {
36 | screen: ProfileScreen,
37 | },
38 | Settings: {
39 | screen: SettingsScreen,
40 | },
41 | Notification: {
42 | screen: NotificationScreen,
43 | }
44 | }
45 | });
46 | ```
47 |
48 | With dynamic config API:
49 |
50 | ```js
51 | import { createModalNavigator } from 'react-navigation-native-modal';
52 |
53 | const Modal = createModalNavigator();
54 |
55 | function MyModal() {
56 | return (
57 |
58 |
59 |
60 |
61 |
62 |
63 | );
64 | }
65 | ```
66 |
67 | Then you can navigate to any screen to show it as a modal:
68 |
69 | ```js
70 | navigation.navigate('Profile');
71 | ```
72 |
73 | The first screen in the stack is always rendered as a normal screen and not as a modal. But any subsequent screens will be rendered as modals.
74 |
75 | ### Options
76 |
77 | All of the [props available on `Modal` component](https://reactnative.dev/docs/modal#props) can be specified in [options](https://reactnavigation.org/docs/screen-options) to configure the screens in the navigator, except `visible`, `onDismiss`, `onOrientationChange`, `onRequestClose` and `onShow`.
78 |
79 | With static config API:
80 |
81 | ```js
82 | Profile: {
83 | screen: ProfileScreen,
84 | options: {
85 | animationType: 'fade',
86 | },
87 | },
88 | ```
89 |
90 | With dynamic config API:
91 |
92 | ```js
93 |
100 | ```
101 |
102 | Some of the defaults are different from the `Modal` component:
103 |
104 | - `animationType` is set to `slide` instead of `none`
105 |
106 | ### Events
107 |
108 | The navigator can [emit events](https://reactnavigation.org/docs/navigation-events) on certain actions. Supported events are:
109 |
110 | #### `orientationChange`
111 |
112 | This event is fired when the orientation changes while the modal is being displayed and on initial render. Same as the [`onOrientationChange` prop](https://reactnative.dev/docs/modal#onorientationchange).
113 |
114 | It receives an object in the `data` property of the event, which contains the key `orientation` with the value `portrait` or `landscape`:
115 |
116 | ```js
117 | console.log(e.data) // { orientation: 'portrait' }
118 | ```
119 |
120 | Example:
121 |
122 | ```js
123 | React.useEffect(() => {
124 | const unsubscribe = navigation.addListener('orientationChange', (e) => {
125 | // Do something
126 | });
127 |
128 | return unsubscribe;
129 | }, [navigation]);
130 | ```
131 |
132 | Only supported on iOS.
133 |
134 | ### Helpers
135 |
136 | The modal navigator adds the following methods to the navigation prop:
137 |
138 | #### `push`
139 |
140 | Pushes a new screen to top of the modal stack and navigate to it. The method accepts following arguments:
141 |
142 | - `name` - Name of the route to push onto the modal stack.
143 | - `params` - Screen params to merge into the destination route (found in the pushed screen through `route.params`).
144 |
145 | ```js
146 | navigation.push('Profile', { owner: 'Jane' });
147 | ```
148 |
149 | #### `pop`
150 |
151 | Pops the current screen from the modal stack and navigates back to the previous screen. It takes one optional argument (`count`), which allows you to specify how many screens to pop back by.
152 |
153 | ```js
154 | navigation.pop();
155 | ```
156 |
157 | ### `popTo`
158 |
159 | Navigates back to a previous screen in the stack by popping screens after it. The method accepts the following arguments:
160 |
161 | - `name` - string - Name of the route to navigate to.
162 | - `params` - object - Screen params to pass to the destination route.
163 | - `options` - Options object containing the following properties:
164 | - `merge` - boolean - Whether params should be merged with the existing route params, or replace them (when navigating to an existing screen). Defaults to `false`.
165 |
166 | If a matching screen is not found in the stack, this will pop the current screen and add a new screen with the specified name and params.
167 |
168 | ```js
169 | navigation.popTo('Profile', { owner: 'Jane' });
170 | ```
171 |
172 | #### `popToTop`
173 |
174 | Pops all of the screens in the modal stack except the first one and navigates to it.
175 |
176 | ```js
177 | navigation.popToTop();
178 | ```
179 |
180 | ## Gotchas
181 |
182 | The modal navigator is always shown above other navigators since it renders a native modal. This means that if you have a regular stack navigator as the parent of the modal navigator and push a screen in the parent stack, it won't appear above the modal navigator.
183 |
184 | So it's a good practice to always have the modal navigator at the root to avoid such issues instead of nesting it.
185 |
186 | ## Contributing
187 |
188 | See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
189 |
190 | [build-badge]: https://img.shields.io/circleci/project/github/satya164/react-navigation-native-modal/main.svg?style=flat-square
191 | [build]: https://circleci.com/gh/satya164/react-navigation-native-modal
192 | [version-badge]: https://img.shields.io/npm/v/react-navigation-native-modal.svg?style=flat-square
193 | [package]: https://www.npmjs.com/package/react-navigation-native-modal
194 | [license-badge]: https://img.shields.io/npm/l/react-navigation-native-modal.svg?style=flat-square
195 | [license]: https://opensource.org/licenses/MIT
196 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project.
4 |
5 | ## Development workflow
6 |
7 | To get started with the project, run `yarn bootstrap` in the root directory to install the required dependencies for each package:
8 |
9 | ```sh
10 | yarn bootstrap
11 | ```
12 |
13 | While developing, you can run the [example app](/example/) to test your changes.
14 |
15 | To start the packager:
16 |
17 | ```sh
18 | yarn example start
19 | ```
20 |
21 | To run the example app on Android:
22 |
23 | ```sh
24 | yarn example android
25 | ```
26 |
27 | To run the example app on iOS:
28 |
29 | ```sh
30 | yarn example ios
31 | ```
32 |
33 | Make sure your code passes TypeScript and ESLint. Run the following to verify:
34 |
35 | ```sh
36 | yarn typescript
37 | yarn lint
38 | ```
39 |
40 | To fix formatting errors, run the following:
41 |
42 | ```sh
43 | yarn lint --fix
44 | ```
45 |
46 | Remember to add tests for your change if possible. Run the unit tests by:
47 |
48 | ```sh
49 | yarn test
50 | ```
51 |
52 | ### Commit message convention
53 |
54 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages:
55 |
56 | - `fix`: bug fixes, e.g. fix crash due to deprecated method.
57 | - `feat`: new features, e.g. add new method to the module.
58 | - `refactor`: code refactor, e.g. migrate from class components to hooks.
59 | - `docs`: changes into documentation, e.g. add usage example for the module..
60 | - `test`: adding or updating tests, eg add integration tests using detox.
61 | - `chore`: tooling changes, e.g. change CI config.
62 |
63 | Our pre-commit hooks verify that your commit message matches this format when committing.
64 |
65 | ### Linting and tests
66 |
67 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/)
68 |
69 | We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing.
70 |
71 | Our pre-commit hooks verify that the linter and tests pass when committing.
72 |
73 | ### Scripts
74 |
75 | The `package.json` file contains various scripts for common tasks:
76 |
77 | - `yarn bootstrap`: setup project by installing all dependencies and pods.
78 | - `yarn typescript`: type-check files with TypeScript.
79 | - `yarn lint`: lint files with ESLint.
80 | - `yarn test`: run unit tests with Jest.
81 | - `yarn example start`: start the Metro server for the example app.
82 | - `yarn example android`: run the example app on Android.
83 | - `yarn example ios`: run the example app on iOS.
84 |
85 | ### Sending a pull request
86 |
87 | > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
88 |
89 | When you're sending a pull request:
90 |
91 | - Prefer small pull requests focused on one change.
92 | - Verify that linters and tests are passing.
93 | - Review the documentation to make sure it looks good.
94 | - Follow the pull request template when opening a pull request.
95 | - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue.
96 |
97 | ## Code of Conduct
98 |
99 | ### Our Pledge
100 |
101 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
102 |
103 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
104 |
105 | ### Our Standards
106 |
107 | Examples of behavior that contributes to a positive environment for our community include:
108 |
109 | - Demonstrating empathy and kindness toward other people
110 | - Being respectful of differing opinions, viewpoints, and experiences
111 | - Giving and gracefully accepting constructive feedback
112 | - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
113 | - Focusing on what is best not just for us as individuals, but for the overall community
114 |
115 | Examples of unacceptable behavior include:
116 |
117 | - The use of sexualized language or imagery, and sexual attention or
118 | advances of any kind
119 | - Trolling, insulting or derogatory comments, and personal or political attacks
120 | - Public or private harassment
121 | - Publishing others' private information, such as a physical or email
122 | address, without their explicit permission
123 | - Other conduct which could reasonably be considered inappropriate in a
124 | professional setting
125 |
126 | ### Enforcement Responsibilities
127 |
128 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
129 |
130 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
131 |
132 | ### Scope
133 |
134 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
135 |
136 | ### Enforcement
137 |
138 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly.
139 |
140 | All community leaders are obligated to respect the privacy and security of the reporter of any incident.
141 |
142 | ### Enforcement Guidelines
143 |
144 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
145 |
146 | #### 1. Correction
147 |
148 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
149 |
150 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
151 |
152 | #### 2. Warning
153 |
154 | **Community Impact**: A violation through a single incident or series of actions.
155 |
156 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
157 |
158 | #### 3. Temporary Ban
159 |
160 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
161 |
162 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
163 |
164 | #### 4. Permanent Ban
165 |
166 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
167 |
168 | **Consequence**: A permanent ban from any sort of public interaction within the community.
169 |
170 | ### Attribution
171 |
172 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
173 | available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
174 |
175 | Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
176 |
177 | [homepage]: https://www.contributor-covenant.org
178 |
179 | For answers to common questions about this code of conduct, see the FAQ at
180 | https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
181 |
--------------------------------------------------------------------------------