Giter Site home page Giter Site logo

spaghettic0des / react-native-navigation-register-screens Goto Github PK

View Code? Open in Web Editor NEW
25.0 2.0 1.0 1.26 MB

This is a utility function to register an array of screens instead of calling `Navigation.registerComponent` multiple times

License: MIT License

JavaScript 14.78% TypeScript 85.22%
registering-screens react-native-navigation react-native hacktoberfest

react-native-navigation-register-screens's Introduction

react-native-navigation-register-screens

Easier way to register RNN components.

Example

Function Component

import {
  ScreenFC,
} from 'react-native-navigation-register-screens';

type MyFunctionComponentProps = {
  hello: string,
};

const MyFunctionComponent: ScreenFC<MyFunctionComponentProps> = ({
  hello,
  componentId,
}) {
  console.log(componentId);
  return (
    <View>
      <Text>{hello}</Text>
    </View>
  );
};

MyFunctionComponent.screenName = 'MyApp.Screens.MyFunctionComponent';

MyFunctionComponent.options = props => {
  console.log(props);

  return {
    topBar: {
      title: {
        text: 'Pushed screen title',
      },
    },
  };
};

Registering Screens

import {registerScreens} from 'react-native-navigation-register-screens';

registerScreens([MyFunctionComponent, MyClassComponent, MyPureComponent]);

With providers

If your using react-redux's Provider or other similar libraries, you can provide a third parameter as the callback function.

import {Provider} from 'react-redux';
import store from '../store';

registerScreens(
  [MyFunctionComponent, MyClassComponent, MyPureComponent],
  (Component) => (props) => (
    <Provider store={store}>
      <Component {...props} />
    </Provider>
  ),
);

License

react-native-navigation-register-screens is MIT licensed, as found in the LICENSE file.

react-native-navigation-register-screens's People

Contributors

dependabot[bot] avatar spaghettic0des avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

bgonp

react-native-navigation-register-screens's Issues

Refactor types to be more flexible

Currently the types are a little bit buggy/hacky, specially when wrapping the screen component with a HOC (e.g Redux connect).

Refactor the types to handle these situations.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.