Installations
npm install react-simple-stack-navigation
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
12.14.1
NPM Version
6.13.4
Score
68.5
Supply Chain
98.8
Quality
75
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (70.46%)
TypeScript (29.54%)
Developer
renanliberato
Download Statistics
Total Downloads
1,284
Last Day
2
Last Week
11
Last Month
32
Last Year
357
GitHub Statistics
2 Stars
13 Commits
2 Watching
13 Branches
1 Contributors
Bundle Size
944.00 B
Minified
535.00 B
Minified + Gzipped
Package Meta Information
Latest Version
1.1.0
Package Id
react-simple-stack-navigation@1.1.0
Unpacked Size
17.90 kB
Size
4.83 kB
File Count
8
NPM Version
6.13.4
Node Version
12.14.1
Total Downloads
Cumulative downloads
Total Downloads
1,284
Last day
-50%
2
Compared to previous day
Last week
57.1%
11
Compared to previous week
Last month
146.2%
32
Compared to previous month
Last year
158.7%
357
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
React Simple Stack Navigation
Intro
I created this module for a simple prototyping I was working and I did not want to import a full featured navigation module while not necessary.
Installing
npm install react-simple-stack-navigation
How to use
This module exposes just 1 function: useNavigation
. It is a React hook that has what is needed to check the navigation stack and push/pop screens to it.
To exemplify its use, let's assume we have are developing a game and we current have 2 screens MainScreen
and HowToPlayScreen
, but the app still exhibits just the first one:
function App() {
return (
<MainScreen/>
);
}
function MainScreen() {
return (
<>
<h1>THE GAME</h1>
<button>How to play</button>
</>
);
}
function HowToPlayScreen() {
return (
<>
<h1>HOW TO PLAY</h1>
<button>Back</button>
</>
);
}
To add navigation between them, first we need to use our useNavigation
hook. We will use it in a top component to instantiate the first screen and pass the navigation methods to it:
import { useNavigation } from 'react-simple-stack-navigation';
function App() {
const { currentScreen, navigateTo, navigateBack } = useNavigation(MainScreen);
const { ScreenComponent } = currentScreen;
// We can pass additional props to our screen as usual.
return (
<ScreenComponent navigateTo={navigateTo} navigateBack={navigateBack} />
);
}
Then, in our screens, we can use navigateTo
and navigateBack
props to navigate between them.
function MainScreen({navigateTo}) {
return (
<>
<h1>THE GAME</h1>
<button onClick={() => navigateTo(HowToPlayScreen)}>How to play</button>
</>
);
}
function HowToPlayScreen({navigateBack}) {
return (
<>
<h1>HOW TO PLAY</h1>
<button onClick={navigateBack}>Back</button>
</>
);
}
Adding a middleware
When adding useNavigationReducer, we can specify a middleware that will run between navigation calls. This middleware can be used for sending analytics events on page changes, for example.
Let's add it to our app:
import { useNavigation } from 'react-simple-stack-navigation';
function navigationAnalyticsMiddleware(action, next) {
// sendEvent('page_view');
// If you want to prevent navigation, just do not call next(action) and return null.
return next(action);
}
function App() {
const { currentScreen, navigateTo, navigateBack } = useNavigation(MainScreen, {}, navigationAnalyticsMiddleware);
const { ScreenComponent } = currentScreen;
// We can pass additional props to our screen as usual.
return (
<ScreenComponent navigateTo={navigateTo} navigateBack={navigateBack} />
);
}
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/11 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 2 are checked with a SAST tool
Reason
27 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Score
1.3
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to react-simple-stack-navigation
react-native-enroute
Simple and fast React Native router based on react-enroute and native navigation
react-stack-nav
Simple navigation for React.
simple-react-navigation
Easy to setup stack navigation for react and react-native apps using Redux.
indie-expo-stack
A simple Expo template with navigation, testing, and linting setup.