react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

Custom App documentation example - formMiddleware

Open mknapik opened this issue 8 years ago • 8 comments

What you were expecting:

By following tutorial at https://marmelab.com/react-admin/CustomApp.html I should be able to configure custom provider.

What happened instead:

Got an exception:

redux.js:567 Uncaught TypeError: middleware is not a function
    at redux.js:567
    at Array.map (<anonymous>)
    at redux.js:566
    at <anonymous>:1:28482
    at Module.createStore (redux.js:87)
    at Object.configureStore [as default] (configure-store.ts:49)
    at Object../src/redux.ts (redux.ts:9)
    at __webpack_require__ (bootstrap:721)
    at fn (bootstrap:98)
    at Object../src/index.tsx (index.tsx:7)
    at __webpack_require__ (bootstrap:721)
    at fn (bootstrap:98)
    at Object.0 (serializer.ts:4)
    at __webpack_require__ (bootstrap:721)
    at ./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js.module.exports (bootstrap:788)
    at bootstrap:788

Steps to reproduce:

Following the docs for CustomApp.

Related code:

https://github.com/marmelab/react-admin/pull/2249/files#diff-48a1c77367d4a9f0308adfcc0157fc29L17 It seems the middleware was removed and no longer needed.

Environment

  • React-admin version: 2.3.0
  • React version: 16.3.0

Also, it seems the import of formReducer is missing. I guessed it should have been:

import { reducer as formReducer } from 'redux-form'

mknapik avatar Sep 10 '18 16:09 mknapik

This is indeed a documentation issue

djhi avatar Sep 14 '18 14:09 djhi

I think #2339 fixes this, @djhi can you confirm?

fzaninotto avatar Sep 21 '18 08:09 fzaninotto

Nope, I forgot to remove the formReducer...

djhi avatar Sep 21 '18 08:09 djhi

For anyone willing to resolve this: we reintroduced the formMiddleware and removed the formReducer which wasn't the one from redux

djhi avatar Sep 30 '18 08:09 djhi

Hello, I'm trying to create my own store to access from DataProvider but I think I have a similar problem. When I try to implement createAdminStore.js as indicated in the documentation, the following error appears when importing formMiddleware

error: 'react-admin' does not contain an export named 'formMiddleware'.

Versiones React-admin: "2.3.4" React: "16.5.2"

DavidEstebanSaiz avatar Oct 17 '18 10:10 DavidEstebanSaiz

@DavidEstebanSaiz I had the same issue and fixed it this way untill a proper patch will be done. i added formMiddleware this way: import formMiddleware from 'ra-core/lib/form/formMiddleware';

gabkk avatar Nov 13 '18 21:11 gabkk

Seems that this issue still not resolved in 2.4.2, When importing

import { formMiddleware } from 'react-admin';

I am getting:

TypeError: middleware is not a function

When importing it directly from node_modules/ra-core/esm/form/formMiddleware, I am unable to build using CRA scripts with the following error:

Failed to minify the code from this file:

./node_modules/ra-core/src/form/formMiddleware.js:18

dsinai14 avatar Nov 16 '18 17:11 dsinai14

#2696 addresses this issue

fzaninotto avatar Jan 29 '19 14:01 fzaninotto