1.0.17 • Published 6 years ago

rn-gnavigator v1.0.17

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

rn-gnavigator

install cmd:

 npm install rn-gnavigator

Props:

PropsTypedefaultDiscription
initialScreenReact Componentset the initial Screen to the Stack
initialParamAnyemty stringit sets the initial param
initialScreenBackHandlerfunctionexitApp()called when we click backbutton on initial screen
transitionDirectionhorizontal, vertical, normalhorizontalit desides the transiton direction
transitionDurationnumber in ms200it desides the transition duration
transitionnone, fadenoneto add fading animations
typenormal, authnormalmaking login type screens or normal stack
loginScreenReact Componenthere give Login Screen Component
homeScreenReact Componenthere you can give home or dashboard component
loginParamanyemty stringinitial param for login ie. Home Screen
logoutParamanyemty stringinitial param for logut ie. Login Screen

Methods:

There are two components are here

// Here you can push screen
this.props.push({ Screen: Screen, param: data }); // Here the screen is the React Component
// Here you can pop screen
this.props.pop();
// Here you can restart with initial screen
this.props.restart();
// Here you can restart with Home or Dashboard screen
this.props.login();
// Here you can restart with Login screen
this.props.logout();
// Here you can manage common state of Stack
this.props.setState({ some: 'some' }); // Here same like setState method

this methods are send to all the screens via props

Data:

this.props.pushedData // has the sended data to this 2nd screen
this.props.state // common state for all the screen

this will get the data send from previous screen with push() method.

Usage:

import React from 'react';
import { View, Text } from 'react-native';
import { Stack } from 'rn-gnavigator';

class Test extends React.Component {
    render() {
	    return <View style={{
		    flex: 1,
		    backgroundColor: 'red',
		    alignItems: 'center',
		    justifyContent: 'center'
		}}>
			<Text onPress={() => this.props.push(TestPage)}>
				Go to Test Page
			</Text>
		</View>;
    }
}

class TestPage extends React.Component {
    render() {
	    return <View style={{
		    flex: 1,
		    backgroundColor: 'blue',
		    alignItems: 'center',
		    justifyContent: 'center'
		}}>
			<Text onPress={() => this.props.pop()}>
				Go back to Test
			</Text>
		</View>;
    }
}

export default App extends React.Component {
    render() {
	    return <Stack initialScreen={Test} />;
    }
}

TekNik GG

This is a YouTube Channel for react-native exclusively Please Support Our Channel and Click here to SUBSCRIBE

website

Learn Somthing...

Happy Coding...

: )

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago