React.js: How to import dynamically redux action

Viewed 201

Is there any solution to import dynamically below redux action and use it?

import { set } from 'actions/formula-form';

Solved!:

const action = require('actions/' + props.action);
 dispatch(action.set({ formulaId: dataItem.id }));
  };
1 Answers

Try this one

import { set } from 'actions/formula-form';
import { connect } from "react-redux";
...

component() {
...
this.props.getProps(value);
...
}

const mapStateToProps = (state) => ({
  getProps: state.formula-form.data,
});

const mapDispatchToProps = {
  set,
};

export default connect(mapStateToProps, mapDispatchToProps)(DashBoard);
Related