Skip to content

Creates a provider that can be used to dependency inject properties into the React context

Notifications You must be signed in to change notification settings

kmalakoff/react-create-provider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-create-provider

Creates a provider that can be used to dependency-inject properties into the React context

Usage

import React from 'react';
import createProvider from 'react-create-provider';

import createStore from './path/to/create-my-store';
import MainComponent from './path/to/main-component';

let Provider = createProvider({store: React.PropTypes.object.isRequired})
ReactDOM.render(
  <Provider store={createStore()}>
    <MainComponent/>
  </Provider>,
  document.getElementById('app')
);
import React from 'react';

export default class MainComponent extends React.Component {
  static contextTypes = {store: React.PropTypes.object.isRequired};

  render() {
    let {store} = this.context;

    // use the store and render your component
  }
}

About

Creates a provider that can be used to dependency inject properties into the React context

Resources

Stars

Watchers

Forks

Packages

No packages published