These are chat archives for erikras/redux-form

20th
Dec 2017
Iain Freestone
@iainfreestone
Dec 20 2017 13:27
Hi all, I am in the early stages of designing my first JS app. One of my main requirements is that when Customer 1 logs in they get access to Component X and Y, and when Customer 2 logs in they get access to Component A and Component B. Customer 1 will never have access visually or by digging into the code Customers 2 components due to IP/Copyright restrictions. I have been reading about Lazy loading and Webpack is this what I would use to restrict access to a particular customer?
hopefully that make sense
Rhys van der Waerden
@rhys-vdw
Dec 20 2017 13:28
@iainfreestone This is not the correct room for that question. Perhaps try the webpack room?
Iain Freestone
@iainfreestone
Dec 20 2017 13:29
ops sorry i thought I had clicked on webpack convo thanks
Rhys van der Waerden
@rhys-vdw
Dec 20 2017 13:29
:ok_hand:
Iain Freestone
@iainfreestone
Dec 20 2017 13:31
although thinking about it i do have a redux-form question!

I am trying to use redux-form reducer.plugin() with dynamically generated form names but am running in to problems as the reducer plugin requires the name of the form and I may not know that before execution.

In the case below it works fine if I know my form is called foo but in my app I have multiple forms dynamically named such as CalcForm1, CalcForm2 .... CalcFormN etc. which all require the functionality of the "CALCULATE" action.type

Is there a why I can use this with dynamically named forms.

export const formPlugin = {
  foo: (state = {}, action) => { // <----- 'foo' is name of form given to     reduxForm()
    switch (action.type) {
      case "CALCULATE":
        return {
          ...state,
          values: doCalculate(action.payload.expressions, state.values)
        };

      default:
        return state;
    }
  }
};
Rhys van der Waerden
@rhys-vdw
Dec 20 2017 13:38
@iainfreestone it doesn't look like there's an easy way...
Rhys van der Waerden
@rhys-vdw
Dec 20 2017 13:44
@iainfreestone (I wrote some other stuff but deleted it because it was wrong)
Iain Freestone
@iainfreestone
Dec 20 2017 13:55
@rhys-vdw ok thanks, yeah does not seem an easy way. Thanks for replying
Rhys van der Waerden
@rhys-vdw
Dec 20 2017 23:18
Oh @iainfreestone maybe I was right actually... I think you can set form as an argument to meta... see source... Perhaps try it out.