Partage
  • Partager sur Facebook
  • Partager sur Twitter

[REACT REDUX FORM] Object(...) is not a function

TypeError: Object(...) is not a function

    18 avril 2019 à 23:10:46

    Bonjour à tous,

    j'ai suivi le tuto de la page suivante : http://davidkpiano.github.io/react-redux-form/docs/guides/quickstart.html pour mettre en place un redux form. Cependant j'ai l'erreur suivante :

    TypeError: Object(...) is not a function
    ConnectFunction
    node_modules/react-redux/es/components/connectAdvanced.js:116
      113 | };
    114 |
    115 | function ConnectFunction(props) {
    > 116 | var _useMemo = useMemo(function () {
    | ^ 117 | // Distinguish between actual "data" props that were passed to the wrapper component,
    118 | // and values needed to control behavior (forwarded refs, alternate context instances).
    119 | // To maintain the wrapperProps object reference, memoize this destructuring.

    Je vous donne mon code :

    App.js

    import React, { Component } from 'react';
    import './App.css';
    import { Provider } from 'react-redux';
    import store from './Redux/store.js';
    import AlbumForm from './Components/Form/AlbumForm';
    
    
    class App extends Component {
    
      render() {
        return (
          <Provider store={store}>
            <AlbumForm />
          </Provider>
        );
      }
    }
    
    export default App;
    

    store.js

    import { createStore, combineReducers, applyMiddleware } from 'redux';
    import { combineForms, createForms } from 'react-redux-form';
      
    const initialAlbumFormState = {
       name: '',
    };
      
    const store = createStore(combineForms({
         album: initialAlbumFormState,
    }));
    
    export default store;


    AlbumForm.js

    import React from 'react';
    import { connect } from 'react-redux';
    import { Control, Form, Errors, reduxForm } from 'react-redux-form';
    
    class AlbumForm extends React.Component {
      handleSubmit(album) {
        console.log('test')
      }
      
      render() {
        return (
          <Form
            model="album"
            onSubmit={(album) => this.handleSubmit(album)}
          >
            <label htmlFor="album.name">Name:</label>
            <Control.text
              model="album.name"
              validators={{
                required: (val) => !!val.length,
                minLength: (val) => val.length > 3,
              }}
            />
            <Errors
              model="album.name"
              messages={{
                required: 'Name is required.',
                minLength: 'Name must be more than 3 characters.',
              }}
            />
    
            <button type="submit">
              Finish registration!
            </button>
          </Form>
        );
      }
    }
    
    export default AlbumForm;

    dans ce dernier fichier si je fais :

    render() {
      return <p>Test</p>
    }

    je n'ai aucun problème.

    Quelqu'un aurait une idée ?




    • Partager sur Facebook
    • Partager sur Twitter
      21 avril 2019 à 11:35:24

      Personne ne saurait me dire ? Ou m'aiguiller vers un tuto qui fonctionne ?
      • Partager sur Facebook
      • Partager sur Twitter
        3 juin 2019 à 15:14:09

        I was getting the same error - 

        I just downgraded my redux version -  "react-redux": "^6.0.0",

        Its working for me now.

        • Partager sur Facebook
        • Partager sur Twitter

        [REACT REDUX FORM] Object(...) is not a function

        × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
        × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
        • Editeur
        • Markdown