Ant-design-pro: Antd pro + redux-form

Created on 27 Jun 2019  ·  8Comments  ·  Source: ant-design/ant-design-pro

Hi everyone,

Is there a way to add redux form reducer to antd pro?

Thank you su much

All 8 comments

I don't know much about redux form. What trouble did you encounter?

Hi and thank you for taking the time to look at this.
Redux-form works with redux store using its own reducer, and I don’t know how to add an external reducer with dva architecture that is used by ant design pro.
This is from redux form doc

import { createStore, combineReducers } from 'redux'
import { reducer as formReducer } from 'redux-form'

const rootReducer = combineReducers({
  // ...your other reducers here
  // you have to pass formReducer under 'form' key,
  // for custom keys look up the docs for 'getFormState'
  form: formReducer
})

const store = createStore(formReducer)

the question is how to add a new reducer that uses redux store?
Is it possible to add reducers from external librairies that uses redux store for state management?

Thank you so much, your help is really appreciated!

you need this https://dvajs.com/api/#app-use-hooks。
you can write it in src/app.ts.
Umi will load it automatically

Thank you I’ll check this out!

There is no src/app.js in ant design pro template project, when I go to the source code I don’t see one. Does this mean I need to create one?

ant-design-pro

Is it possible for you to provide a small example please?
Or maybe just tell where this code should go in the ant design pro template:

import { reducer as formReducer } from 'redux-form'
const app = dva({
  extraReducers: {
    form: formReducer,
  },
});

Thank you so much!

https://umijs.org/guide/app-structure.html#src-app-js-ts

you can look here. this is a agreement

This didn't work and I'm still stuck with this. Can you please help?

Submit a question in dva

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yaoleiroyal picture yaoleiroyal  ·  3Comments

Jerry-goodboy picture Jerry-goodboy  ·  3Comments

RichardStark picture RichardStark  ·  3Comments

suifan picture suifan  ·  3Comments

yjz1004 picture yjz1004  ·  3Comments