Home

Awesome

vidom-redux

Build Status NPM Version

What is it?

This module provides Redux bindings for Vidom.

Installation

npm i vidom-redux

API

This module provides:

Provider

Provider expects store attribute to be passed.

import { mount } from 'vidom';
import { createStore } from 'redux';
import { Provider } from 'vidom-redux';
import App from './components/App';
import reducer from './reducers';

const store = createStore(reducer);

mount(
    document.getElementById('root'),
    <Provider store={ store }>
        <App/>
    </Provider>);

connect

connect wraps and connects given component to a new one which is connected to a store.

It returns a function to wrap given component.

import { Component } from 'vidom';
import { connect } from 'vidom-redux';
import * as actions from '../actions';

class MyComponent extends Component {
    ...
}

const storeStateToAttrs = ({ subState1, subState2 }) => ({ subState1, subState2 }),
    MyConnectedComponent = connect(storeStateToAttrs, actions)(MyComponent);