Search code examples
reactjsreduxreact-reduxfluxreactjs-flux

Flux Actions to Redux Actions Conversion


Hi I have an action setup but its in flux, and I need to refactor it to match with Redux actions.

Any help would be highly appreciated with migrating both to redux.


Solution

  • Answering your questino from the comments;

    How do I use my bind functions as in this reducer with redux? Anad how would I go about this.emit("change") in redux?

    In redux, you connect your component to the Redux State as follows:

    ReduxEnabledComponent = ReactRedux.connect(
        function(state) {
            return {
                someProp: state.someProp
            },
        {
            someAction: function(){
                return {type: 'action_type', data: {}}
            }
        }
    )(Component);
    

    The above code would take a component named Component and connect it to the Redux Store. This component would receive props of someProp, which is a value of the Redux Store, as well as someAction, which is a method to use for emitting a request to the store.