# react-navigation-steps

> Custom step-by-step navigator for react-navigation

Latest version **1.0.2** (published 2023-02-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-navigation-steps
pnpm add react-navigation-steps
yarn add react-navigation-steps
bun add react-navigation-steps
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-02-19 |
| First published | 2022-12-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Daniel Palma |
| Maintainers | dpalma |
| Keywords | react, react-native, react-navigation |

## Links

- npm: https://www.npmjs.com/package/react-navigation-steps
- Repository: https://github.com/dpalma/react-navigation-steps
- Homepage: https://github.com/dpalma/react-navigation-steps#readme
- Issues: https://github.com/dpalma/react-navigation-steps/issues
- npm.io page: https://npm.io/package/react-navigation-steps

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2023-02-19
- 1.0.0 — 2022-12-09

## README

# React Navigation Steps

A [react-navigation](https://reactnavigation.org/) custom navigator that can be used to implement a step-by-step wizard component.

## Installation

```shell
$ npm install react-navigation-steps
```

## Properties

|Property|Description|Required?|
|-|-|-|
|renderButtonBar|A function that renders a button bar with buttons for moving to the next or previous step and the title of the current step. The function takes an object with fields for react-navigation `state`, `navigation`, and `descriptors` as given by [useNavigationBuilder](https://reactnavigation.org/docs/custom-navigators).|No|
|renderIndicator|A function that renders a progress indicator using the current step and the total number of steps.|No|


## Events

### prevPress | nextPress

These events are fired before navigating to the previous or next screen.

The default action can be cancelled by calling `event.preventDefault()`. This will force the wizard to remain on the current step.

#### Example
```javascript
React.useEffect(() => {
    return navigation.addListener('nextPress', event => {
        event.preventDefault();
    });
}, [navigation]);
```


## Usage

### Basics

```javascript
import { createSteps } from 'react-navigation-steps';

const Steps = createSteps();

render() {
    <Steps.Navigator>
        <Steps.Screen component={StepOne} name='Step1'></Steps.Screen>
        <Steps.Screen component={StepTwo} name='Step2'></Steps.Screen>
        ...
        <Steps.Screen component={StepN} name='StepN'></Steps.Screen>
    </Steps.Navigator>
}
```

### Controlling flow through steps

The default button bar emits events nextPress and prevPress when the next and previous step buttons are pressed. A step may listen for these events by registering an event listener as shown below. By calling `preventDefault` on the event object the step can prevent the wizard from proceeding to the next or previous step. The `navigation` object will have methods `nextStep`, `prevStep`, `firstStep`, and `lastStep` for moving through the steps under the app's control.

```javascript
import { createSteps } from 'react-navigation-steps';

const Steps = createSteps();

const StepOne = ({navigation}) => {

    React.useEffect(() => {
        return navigation.addListener('nextPress', event => {
            event.preventDefault();
            submitData(data).then(() => navigation.nextStep());
        });
    }, [navigation]);

    return (
        <View>...<View>
    );
};

render() {
    <Steps.Navigator>
        <Steps.Screen component={StepOne} name='Step1'></Steps.Screen>
        <Steps.Screen component={StepTwo} name='Step2'></Steps.Screen>
        ...
        <Steps.Screen component={StepN} name='StepN'></Steps.Screen>
    </Steps.Navigator>
}
```

---
_Source: https://npm.io/package/react-navigation-steps · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
