npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@robotalienunicorn/react-native-redux-router

v0.0.4

Published

A React Native Redux Router

Downloads

6

Readme

react-native-redux-router

codecov

A react-native-screens router built on @reduxjs/toolkit

Basic Usage

// Define your screen names and your screen renderer

export type AppScreens = 'home' | 'about' | 'user'

export function AppScreen({screen, params}: {screen: AppScreens, params: any}) {
	switch (screen) {
		case 'home':
			return <HomeScreen params={params}>
		case 'about':
			return <AboutScreen params={params}>
		case 'user':
			return <UserScreen params={params}>
	}
}
// Create your router slice with it's initial state

import { createRouterSlice } from '@robotalientunicorn/react-native-redux-router';

// This is example shows all the different navigators and screens you can make
const routerSlice = createRouterSlice<AppScreens>({
  name: 'root',
  type: NavigatorType.stack,
  routes: [
    {
      name: 'stack1',
      type: NavigatorType.stack,
      routes: [{ name: 'screen1', params: 'hello-world' }],
    },
    {
      name: 'tab',
      type: NavigatorType.tab,
      activeRoute: 'tab1',
      routes: [
        {
          name: 'tab1',
          type: NavigatorType.stack,
          routes: [
            {
              name: 'tab1screen',
            },
          ],
        },
        {
          name: 'tab2',
          type: NavigatorType.stack,
          routes: [
            {
              name: 'tab2screen',
            },
          ],
        },
        {
          name: 'tab3',
          type: NavigatorType.stack,
          routes: [
            {
              name: 'tab3screen',
            },
          ],
        },
      ],
    },
    {
      name: 'switch',
      type: NavigatorType.switch,
      activeRoute: 'switch1',
      routes: [
        {
          name: 'switch1',
          type: NavigatorType.stack,
          routes: [
            {
              name: 'switch1screen',
            },
          ],
        },
        {
          name: 'switch2',
          type: NavigatorType.stack,
          routes: [
            {
              name: 'switch2screen',
            },
          ],
        },
        {
          name: 'switch3',
          type: NavigatorType.stack,
          routes: [
            {
              name: 'switch3screen',
            },
          ],
        },
      ],
    },
    {
      name: 'stack2',
      type: NavigatorType.stack,
      routes: [
        { name: '2-1' },
        { name: '2-2' },
        { name: '2-3' },
        { name: '2-4' },
      ],
    },
    {
      name: 'stack3',
      type: NavigatorType.stack,
      routes: [
        { name: '3-1' },
        { name: '3-2' },
        { name: '3-3' },
        { name: '3-4' },
      ],
    },
  ],
});
// Add your router slice to your redux store

const store = configureStore({
  reducer: {
    router: routerSlice.router,
  },
});
export type AppState = ReturnType<typeof store.getState>;
// Create your ReduxRouter component and render

const ReduxRouter = createReduxRouter({
  slice: routerSlice,
  selector: (state) => (state as AppState).router,
});

function App() {
  // don't forget your provider
  return (
    <Provider store={store}>
      <ReduxRouter Screens={AppScreen} />
    </Provider>
  );
}

hooks

import {
  useNavigation,
  useFocus,
  FocusEvents,
} from '@robotalienunicorn/react-native-redux-router';

function MyComponent() {
  const navigation = useNavigation();
  const [state, setState] = useState<FocusEvents>('focus');
  useFocus((event: FocusEvents) => {
    setState(event);
  });
  return (
    <Button
      onPress={() => {
        navigation.push({ name: 'user', params: { id: getUserId() } });
      }}
      title={`Hello nav ${state}`}
    />
  );
}