Unable to read "submit" undefined 'properties. to react

Below is the code I'm using. I get an error, for example Uncaught TypeError: Cannot read property 'dispatch' of undefined. I also want to perform an dispatchaction.

import { connect } from 'react-redux'
let SearchBar = ({ dispatch }) => {
    let input
    return (
       <div>
           <form>
              <input type="text" placeholder="Search"  />
              <p>
                 <input type="checkbox" />
                 {' '}
                 Free
              </p>                
           </form>
       </div>
   )
}

SearchBar = connect()(SearchBar)
export default SearchBar()
+4
source share
3 answers

A few things I noticed right away with your sample code:

First of all, the function connectrequires some parameters in the first bracket, even if this parameter is null, also I do not think that you need the brackets in the export line. Try replacing these last two lines with something like this:

export default connect(null)(SearchBar);

look, it doesnโ€™t matter.

0
source

dispatch connect. connect - dispatch

,

export default SearchBar();

() SearchBar . ,

var search = connect()(SearchBar)
export default search;

,

export default connect()(SearcBar);

, .

+1

mapStateToProps .

const mapStateToProps = state => ({
  uData: state
});

export default connect(mapStateToProps)(App);

connect().

, .

0
source

Source: https://habr.com/ru/post/1670420/


All Articles