docs: add basic README files

This commit is contained in:
satyajit.happy
2019-08-21 19:11:32 +05:30
parent 1c2e5de07a
commit 6970ad7b7b
9 changed files with 473 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
# `@react-navigation/bottom-tabs`
Bottom tab navigator for React Navigation following iOS design guidelines.
## Installation
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/bottom-tabs
```
## Usage
```js
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
const BottomTabs = createBottomTabNavigator();
export default function App() {
return (
<BottomTabs.Navigator>
<BottomTabs.Screen
name="article"
component={Article}
options={{
tabBarLabel: 'Article',
tabBarIcon: 'chrome-reader-mode',
}}
/>
<BottomTabs.Screen
name="chat"
component={Chat}
options={{
tabBarLabel: 'Chat',
tabBarIcon: 'chat-bubble',
}}
/>
<BottomTabs.Screen
name="contacts"
component={Contacts}
options={{
tabBarLabel: 'Contacts',
tabBarIcon: 'contacts',
}}
/>
</BottomTabs.Navigator>
);
}
```

38
packages/core/README.md Normal file
View File

@@ -0,0 +1,38 @@
# `@react-navigation/core`
Core utilities for building navigators.
## Installation
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/core
```
## Usage
A basic custom navigator bundling a router and a view looks like this:
```js
import { useNavigationBuilder } from '@react-navigation/core';
import { StackRouter } from '@react-navigation/routers';
function StackNavigator({ initialRouteName, children, ...rest }) {
const { state, navigation, descriptors } = useNavigationBuilder(StackRouter, {
initialRouteName,
children,
});
return (
<StackView
state={state}
navigation={navigation}
descriptors={descriptors}
{...rest}
/>
);
}
export default createNavigator(StackNavigator);
```

74
packages/drawer/README.md Normal file
View File

@@ -0,0 +1,74 @@
# `@react-navigation/drawer`
Bottom tab navigator for React Navigation following iOS design guidelines.
## Installation
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/drawer
```
Now we need to install [`react-native-gesture-handler`](https://github.com/kmagiera/react-native-gesture-handler) and [`react-native-reanimated`](https://github.com/kmagiera/react-native-reanimated).
If you are using Expo, to ensure that you get the compatible versions of the libraries, run:
```sh
expo install react-native-gesture-handler react-native-reanimated
```
If you are not using Expo, run the following:
```sh
yarn add react-native-reanimated react-native-gesture-handler
```
If you are using Expo, you are done. Otherwise, continue to the next steps.
Next, we need to link these libraries. The steps depends on your React Native version:
- **React Native 0.60 and higher**
On newer versions of React Native, [linking is automatic](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md).
To complete the linking on iOS, make sure you have [Cocoapods](https://cocoapods.org/) installed. Then run:
```sh
cd ios
pod install
cd ..
```
- **React Native 0.59**
If you're on an older React Native version, you need to manually link the dependencies. To do that, run:
```sh
react-native link react-native-reanimated
react-native link react-native-gesture-handler
```
**IMPORTANT:** There are additional steps required for `react-native-gesture-handler` on Android after linking (for all React Native versions). Check the [this guide](https://kmagiera.github.io/react-native-gesture-handler/docs/getting-started.html) to complete the installation.
## Usage
```js
import { createDrawerNavigator } from '@react-navigation/drawer';
const Drawer = createDrawerNavigator();
export default function App() {
return (
<Drawer.Navigator>
<Drawer.Screen name="home" component={Home} options={{ title: 'Home' }} />
<Drawer.Screen name="feed" component={Feed} options={{ title: 'Feed' }} />
<Drawer.Screen
name="profile"
component={Profile}
options={{ title: 'Profile' }}
/>
</Drawer.Navigator>
);
}
```

View File

@@ -0,0 +1,7 @@
# Example for React Navigation
If you want to run the example from the repo,
- Clone the repository and run `lerna bootstrap` in the root
- Run `yarn example start` to start the packager
- Follow the instructions to open it with the [Expo app](https://expo.io/)

View File

@@ -0,0 +1,60 @@
# `@react-navigation/material-bottom-tabs`
React Navigation integration for [bottom navigation](https://material.io/design/components/bottom-navigation.html) component from [`react-native-paper`](https://callstack.github.io/react-native-paper/bottom-navigation.html).
## Installation
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/material-bottom-tabs
```
Setup `react-native-paper` following the [Getting Started guide](https://callstack.github.io/react-native-paper/getting-started.html).
## Usage
```js
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
const MaterialBottomTabs = createMaterialBottomTabNavigator();
export default function App() {
return (
<MaterialBottomTabs.Navigator>
<MaterialBottomTabs.Screen
name="article"
component={Article}
options={{
tabBarLabel: 'Article',
tabBarIcon: 'chrome-reader-mode',
}}
/>
<MaterialBottomTabs.Screen
name="chat"
component={Chat}
options={{
tabBarLabel: 'Chat',
tabBarIcon: 'chat-bubble',
}}
/>
<MaterialBottomTabs.Screen
name="contacts"
component={Contacts}
options={{
tabBarLabel: 'Contacts',
tabBarIcon: 'contacts',
}}
/>
<MaterialBottomTabs.Screen
name="albums"
component={Albums}
options={{
tabBarLabel: 'Albums',
tabBarIcon: 'photo-album',
}}
/>
</MaterialBottomTabs.Navigator>
);
}
```

View File

@@ -0,0 +1,82 @@
# `@react-navigation/material-top-tabs`
React Navigation integration for animated tab view component from [`react-native-tab-view`](https://github.com/react-native-community/react-native-tab-view).
## Installation
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/material-top-tabs react-native-tab-view
```
Now we need to install [`react-native-gesture-handler`](https://github.com/kmagiera/react-native-gesture-handler) and [`react-native-reanimated`](https://github.com/kmagiera/react-native-reanimated).
If you are using Expo, to ensure that you get the compatible versions of the libraries, run:
```sh
expo install react-native-gesture-handler react-native-reanimated
```
If you are not using Expo, run the following:
```sh
yarn add react-native-reanimated react-native-gesture-handler
```
If you are using Expo, you are done. Otherwise, continue to the next steps.
Next, we need to link these libraries. The steps depends on your React Native version:
- **React Native 0.60 and higher**
On newer versions of React Native, [linking is automatic](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md).
To complete the linking on iOS, make sure you have [Cocoapods](https://cocoapods.org/) installed. Then run:
```sh
cd ios
pod install
cd ..
```
- **React Native 0.59**
If you're on an older React Native version, you need to manually link the dependencies. To do that, run:
```sh
react-native link react-native-reanimated
react-native link react-native-gesture-handler
```
**IMPORTANT:** There are additional steps required for `react-native-gesture-handler` on Android after linking (for all React Native versions). Check the [this guide](https://kmagiera.github.io/react-native-gesture-handler/docs/getting-started.html) to complete the installation.
## Usage
```js
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs';
const MaterialTopTabs = createMaterialTopTabNavigator();
export default function App() {
return (
<MaterialTopTabs.Navigator>
<MaterialTopTabs.Screen
name="article"
component={Article}
options={{ tabBarLabel: 'Article' }}
/>
<MaterialTopTabs.Screen
name="chat"
component={Chat}
options={{ tabBarLabel: 'Chat' }}
/>
<MaterialTopTabs.Screen
name="contacts"
component={Contacts}
options={{ tabBarLabel: 'Contacts' }}
/>
</MaterialTopTabs.Navigator>
);
}
```

48
packages/native/README.md Normal file
View File

@@ -0,0 +1,48 @@
# `@react-navigation/native`
React Native integration for React Navigation
## Installation
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/native
```
## Usage
```js
const ref = React.useRef();
useBackButton(ref);
const { getInitialState } = useLinking(ref, {
prefixes: ['https://myapp.com', 'myapp://'],
});
const [isReady, setIsReady] = React.useState(false);
const [initialState, setInitialState] = React.useState();
React.useEffect(() => {
getInitialState()
.catch(() => {})
.then(state => {
if (state !== undefined) {
setInitialState(state);
}
setIsReady(true);
});
}, [getInitialState]);
if (!isReady) {
return null;
}
return (
<NavigationContainer initialState={initialState} ref={ref}>
{/* content */}
</NavigationContainer>
);
```

View File

@@ -0,0 +1,40 @@
# `@react-navigation/routers`
Routers to help build custom navigators.
You probably don't need to use this package directly if you're not building custom navigators.
## Installation
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/core @react-navigation/routers
```
## Usage
A basic custom navigator bundling a router and a view looks like this:
```js
import { useNavigationBuilder } from '@react-navigation/core';
import { StackRouter } from '@react-navigation/routers';
function StackNavigator({ initialRouteName, children, ...rest }) {
const { state, navigation, descriptors } = useNavigationBuilder(StackRouter, {
initialRouteName,
children,
});
return (
<StackView
state={state}
navigation={navigation}
descriptors={descriptors}
{...rest}
/>
);
}
export default createNavigator(StackNavigator);
```

74
packages/stack/README.md Normal file
View File

@@ -0,0 +1,74 @@
# `@react-navigation/stack`
Bottom tab navigator for React Navigation following iOS design guidelines.
## Installation
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/stack
```
Now we need to install [`react-native-gesture-handler`](https://github.com/kmagiera/react-native-gesture-handler) and [`react-native-reanimated`](https://github.com/kmagiera/react-native-reanimated).
If you are using Expo, to ensure that you get the compatible versions of the libraries, run:
```sh
expo install react-native-gesture-handler react-native-reanimated
```
If you are not using Expo, run the following:
```sh
yarn add react-native-reanimated react-native-gesture-handler
```
If you are using Expo, you are done. Otherwise, continue to the next steps.
Next, we need to link these libraries. The steps depends on your React Native version:
- **React Native 0.60 and higher**
On newer versions of React Native, [linking is automatic](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md).
To complete the linking on iOS, make sure you have [Cocoapods](https://cocoapods.org/) installed. Then run:
```sh
cd ios
pod install
cd ..
```
- **React Native 0.59**
If you're on an older React Native version, you need to manually link the dependencies. To do that, run:
```sh
react-native link react-native-reanimated
react-native link react-native-gesture-handler
```
**IMPORTANT:** There are additional steps required for `react-native-gesture-handler` on Android after linking (for all React Native versions). Check the [this guide](https://kmagiera.github.io/react-native-gesture-handler/docs/getting-started.html) to complete the installation.
## Usage
```js
import { createStackNavigator } from '@react-navigation/stack';
const Stack = createStackNavigator();
export default function App() {
return (
<Stack.Navigator>
<Stack.Screen name="home" component={Home} options={{ title: 'Home' }} />
<Stack.Screen name="feed" component={Feed} options={{ title: 'Feed' }} />
<Stack.Screen
name="profile"
component={Profile}
options={{ title: 'Profile' }}
/>
</Stack.Navigator>
);
}
```