New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-navigation-steps

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-navigation-steps

Custom step-by-step navigator for react-navigation

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

React Navigation Steps

A react-navigation custom navigator that can be used to implement a step-by-step wizard component.

Installation

$ npm install react-navigation-steps

Properties

PropertyDescriptionRequired?
renderButtonBarA 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.No
renderIndicatorA 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

React.useEffect(() => {
    return navigation.addListener('nextPress', event => {
        event.preventDefault();
    });
}, [navigation]);

Usage

Basics

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.

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>
}

Keywords

react

FAQs

Package last updated on 19 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts