Skip to content

High Order Component to allow you to use redux without the need of a single root provider

License

Notifications You must be signed in to change notification settings

viniciusdacal/redux-connect-standalone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redux Connect Standalone

This is HOC fuction that allows you to use redux when you aren't able to have a single root Provider in your application. Eg: You are migrating a legacy application to React and has a few react components inside this application.

Before using this, you need to configure your redux store and export it, just like below.

import { createStore } from 'redux';
import rootReducer 'path/to/rootReducer';

const store = createStore(rootReducer)
export default store;

Then, you can create a file named connect, import the store into it and generate you connect function:

import createConnect from 'redux-connect-standalone';
import store from 'path/to/youStore'

export const connect = createConnect(store);

Now, you can use this function the same way you would use react-redux's connect function:

import { connect } from 'path/to/yourConnect';
import TodoList from './TodoList';

export default connect(mapStateToProps, mapDispatchToProps)(TodoList)

License

MIT

About

High Order Component to allow you to use redux without the need of a single root provider

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published