mapDispatchToProps not working. Props empty (error: redux action is not a function)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am receiving this error: this.props.postBooks is not a function.
I have an action - postBooks - which I am trying to dispatch via props.
Here is my component:
"use strict"
import React from 'react'
import {Well,Panel,FormControl,FormGroup,ControlLabel,Button} from 'react-bootstrap'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import {postBooks} from '../../actions/booksActions'
import {findDOMNode} from 'react-dom'
export class BooksForm extends React.Component{
handleSubmit(){
const book = [{
title: findDOMNode(this.refs.title).value,
description: findDOMNode(this.refs.description).value,
price: findDOMNode(this.refs.price).value
}]
this.props.postBooks(book)
}
render(){
return(
<Well>
<Panel>
<FormGroup controlId='title'>
<ControlLabel> Title </ControlLabel>
<FormControl
type='text'
placeholder='Enter Title'
ref='title' />
</FormGroup>
<FormGroup controlId='description'>
<ControlLabel> Enter Description </ControlLabel>
<FormControl
type='text'
placeholder='Enter Description'
ref='description' />
</FormGroup>
<FormGroup controlId='price'>
<ControlLabel> Enter Price </ControlLabel>
<FormControl
type='text'
placeholder='Enter Price'
ref='price' />
</FormGroup>
<Button
onClick={this.handleSubmit.bind(this)}
bsStyle='primary'> Enter New Book </Button>
</Panel>
</Well>
)
}
}
function mapDispatchToProps(dispatch){
return bindActionCreators({postBooks},dispatch)
}
export default connect(null,mapDispatchToProps)(BooksForm);
It seems that dispatch is not being mapped to props as expected since upon console logging props, props are empty. Any help appreciated. Thanks in advance
Edit: Added Actions
"use strict"
// POST A BOOK
export function postBooks(book){
return {
type:"POST_BOOK",
payload: book
}
}
// DELETE A BOOK
export function deleteBooks(id){
return {
type:"DELETE_BOOK",
payload: id
}
}
//UPDATE BOOK
export function updateBooks(book){
return {
type:"UPDATE_BOOK",
payload: book
}
}
//Retrieve all books as if using API
export function getBooks(){
return{
type:'GET_BOOKS'
}
}
reactjs redux react-redux
add a comment |
I am receiving this error: this.props.postBooks is not a function.
I have an action - postBooks - which I am trying to dispatch via props.
Here is my component:
"use strict"
import React from 'react'
import {Well,Panel,FormControl,FormGroup,ControlLabel,Button} from 'react-bootstrap'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import {postBooks} from '../../actions/booksActions'
import {findDOMNode} from 'react-dom'
export class BooksForm extends React.Component{
handleSubmit(){
const book = [{
title: findDOMNode(this.refs.title).value,
description: findDOMNode(this.refs.description).value,
price: findDOMNode(this.refs.price).value
}]
this.props.postBooks(book)
}
render(){
return(
<Well>
<Panel>
<FormGroup controlId='title'>
<ControlLabel> Title </ControlLabel>
<FormControl
type='text'
placeholder='Enter Title'
ref='title' />
</FormGroup>
<FormGroup controlId='description'>
<ControlLabel> Enter Description </ControlLabel>
<FormControl
type='text'
placeholder='Enter Description'
ref='description' />
</FormGroup>
<FormGroup controlId='price'>
<ControlLabel> Enter Price </ControlLabel>
<FormControl
type='text'
placeholder='Enter Price'
ref='price' />
</FormGroup>
<Button
onClick={this.handleSubmit.bind(this)}
bsStyle='primary'> Enter New Book </Button>
</Panel>
</Well>
)
}
}
function mapDispatchToProps(dispatch){
return bindActionCreators({postBooks},dispatch)
}
export default connect(null,mapDispatchToProps)(BooksForm);
It seems that dispatch is not being mapped to props as expected since upon console logging props, props are empty. Any help appreciated. Thanks in advance
Edit: Added Actions
"use strict"
// POST A BOOK
export function postBooks(book){
return {
type:"POST_BOOK",
payload: book
}
}
// DELETE A BOOK
export function deleteBooks(id){
return {
type:"DELETE_BOOK",
payload: id
}
}
//UPDATE BOOK
export function updateBooks(book){
return {
type:"UPDATE_BOOK",
payload: book
}
}
//Retrieve all books as if using API
export function getBooks(){
return{
type:'GET_BOOKS'
}
}
reactjs redux react-redux
Can we see themapDispatchToProps
code?
– Li357
Jul 1 '17 at 22:30
If I understand you correctly, the mapDispatchToProps function is at the bottom of the component code.
– bbmhmmad
Jul 1 '17 at 23:28
add a comment |
I am receiving this error: this.props.postBooks is not a function.
I have an action - postBooks - which I am trying to dispatch via props.
Here is my component:
"use strict"
import React from 'react'
import {Well,Panel,FormControl,FormGroup,ControlLabel,Button} from 'react-bootstrap'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import {postBooks} from '../../actions/booksActions'
import {findDOMNode} from 'react-dom'
export class BooksForm extends React.Component{
handleSubmit(){
const book = [{
title: findDOMNode(this.refs.title).value,
description: findDOMNode(this.refs.description).value,
price: findDOMNode(this.refs.price).value
}]
this.props.postBooks(book)
}
render(){
return(
<Well>
<Panel>
<FormGroup controlId='title'>
<ControlLabel> Title </ControlLabel>
<FormControl
type='text'
placeholder='Enter Title'
ref='title' />
</FormGroup>
<FormGroup controlId='description'>
<ControlLabel> Enter Description </ControlLabel>
<FormControl
type='text'
placeholder='Enter Description'
ref='description' />
</FormGroup>
<FormGroup controlId='price'>
<ControlLabel> Enter Price </ControlLabel>
<FormControl
type='text'
placeholder='Enter Price'
ref='price' />
</FormGroup>
<Button
onClick={this.handleSubmit.bind(this)}
bsStyle='primary'> Enter New Book </Button>
</Panel>
</Well>
)
}
}
function mapDispatchToProps(dispatch){
return bindActionCreators({postBooks},dispatch)
}
export default connect(null,mapDispatchToProps)(BooksForm);
It seems that dispatch is not being mapped to props as expected since upon console logging props, props are empty. Any help appreciated. Thanks in advance
Edit: Added Actions
"use strict"
// POST A BOOK
export function postBooks(book){
return {
type:"POST_BOOK",
payload: book
}
}
// DELETE A BOOK
export function deleteBooks(id){
return {
type:"DELETE_BOOK",
payload: id
}
}
//UPDATE BOOK
export function updateBooks(book){
return {
type:"UPDATE_BOOK",
payload: book
}
}
//Retrieve all books as if using API
export function getBooks(){
return{
type:'GET_BOOKS'
}
}
reactjs redux react-redux
I am receiving this error: this.props.postBooks is not a function.
I have an action - postBooks - which I am trying to dispatch via props.
Here is my component:
"use strict"
import React from 'react'
import {Well,Panel,FormControl,FormGroup,ControlLabel,Button} from 'react-bootstrap'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import {postBooks} from '../../actions/booksActions'
import {findDOMNode} from 'react-dom'
export class BooksForm extends React.Component{
handleSubmit(){
const book = [{
title: findDOMNode(this.refs.title).value,
description: findDOMNode(this.refs.description).value,
price: findDOMNode(this.refs.price).value
}]
this.props.postBooks(book)
}
render(){
return(
<Well>
<Panel>
<FormGroup controlId='title'>
<ControlLabel> Title </ControlLabel>
<FormControl
type='text'
placeholder='Enter Title'
ref='title' />
</FormGroup>
<FormGroup controlId='description'>
<ControlLabel> Enter Description </ControlLabel>
<FormControl
type='text'
placeholder='Enter Description'
ref='description' />
</FormGroup>
<FormGroup controlId='price'>
<ControlLabel> Enter Price </ControlLabel>
<FormControl
type='text'
placeholder='Enter Price'
ref='price' />
</FormGroup>
<Button
onClick={this.handleSubmit.bind(this)}
bsStyle='primary'> Enter New Book </Button>
</Panel>
</Well>
)
}
}
function mapDispatchToProps(dispatch){
return bindActionCreators({postBooks},dispatch)
}
export default connect(null,mapDispatchToProps)(BooksForm);
It seems that dispatch is not being mapped to props as expected since upon console logging props, props are empty. Any help appreciated. Thanks in advance
Edit: Added Actions
"use strict"
// POST A BOOK
export function postBooks(book){
return {
type:"POST_BOOK",
payload: book
}
}
// DELETE A BOOK
export function deleteBooks(id){
return {
type:"DELETE_BOOK",
payload: id
}
}
//UPDATE BOOK
export function updateBooks(book){
return {
type:"UPDATE_BOOK",
payload: book
}
}
//Retrieve all books as if using API
export function getBooks(){
return{
type:'GET_BOOKS'
}
}
reactjs redux react-redux
reactjs redux react-redux
edited Nov 27 '18 at 6:18
Ahmed Elkoussy
1,67021135
1,67021135
asked Jul 1 '17 at 22:27
bbmhmmadbbmhmmad
71110
71110
Can we see themapDispatchToProps
code?
– Li357
Jul 1 '17 at 22:30
If I understand you correctly, the mapDispatchToProps function is at the bottom of the component code.
– bbmhmmad
Jul 1 '17 at 23:28
add a comment |
Can we see themapDispatchToProps
code?
– Li357
Jul 1 '17 at 22:30
If I understand you correctly, the mapDispatchToProps function is at the bottom of the component code.
– bbmhmmad
Jul 1 '17 at 23:28
Can we see the
mapDispatchToProps
code?– Li357
Jul 1 '17 at 22:30
Can we see the
mapDispatchToProps
code?– Li357
Jul 1 '17 at 22:30
If I understand you correctly, the mapDispatchToProps function is at the bottom of the component code.
– bbmhmmad
Jul 1 '17 at 23:28
If I understand you correctly, the mapDispatchToProps function is at the bottom of the component code.
– bbmhmmad
Jul 1 '17 at 23:28
add a comment |
4 Answers
4
active
oldest
votes
Figured it out.
So I was exporting component up top and export default below.
Noticed webpack was giving an error 'import and export may only appear at top level'. Went ahead and removed top export and now works as expected.
1
I'm glad it's working for you now, but I don't think that was actually your issue. the difference betweenexport class BooksForm ...
andexport default connect
is one is imported in another file usingimport { BooksForm } from './BooksForm'
and the other isimport BooksForm from './BooksForm'
(notice the brackets). The way you were exporting was fine, and is often done that way for testing purposes. The webpack error is more likely related to an error in your babel config.
– Michael Peyper
Jul 2 '17 at 11:39
I aslo removed my export from Class line and rebuilt my project, react native. Works now. Thanka.
– Hesam
Nov 18 '17 at 23:18
add a comment |
Faced the same issue and I just removed the curly braces from import
:
From
import {AppTest} from "./AppTest";
To
import AppTest from "./AppTest";
And that seemed to fixed the issue. Note that I had "export default" in my class already.
add a comment |
So I had this same issue & the problem was the same as shown in the other useful answers but I will try to explain why this happens in more details
If we define the class with a default export & a named export as shown here (based on the question):
// named export
export class BooksForm extends React.Component{
.......
function mapDispatchToProps(dispatch){
return bindActionCreators({postBooks},dispatch)
}
// default export
export default connect(null,mapDispatchToProps)(BooksForm);
Then we have to be careful when importing the class to import the default export not the named export:
This imports the default export & shall work correctly with redux
import BooksForm from "./thePath"
This imports the named export & won't work with redux
import { BooksForm } from "./thePath"
If we define the two imports in the same class (which is usually done to make unit testing easier) :
Then we have to import the default export when rendering the component in order to use the redux connect() higher order function that we have exported.
Sometimes if you just depend on the editor autoimport, it will import the named export (which doesn't have the redux connect) & therefore will give that error
Bottom line
You don't have to remove any of the 2 exports, just import the default export (without braces) to use redux connect() correctly
add a comment |
Please try again after importing the redux store. Let me know if that worked or not.And also using refs is not recommended. https://facebook.github.io/react/docs/refs-and-the-dom.html
It didnt work...
– bbmhmmad
Jul 2 '17 at 1:52
Take the curly braces around postBooks inside the bindActionCreators. The action creator should be a function, you gave it an object. I guess that's the problem. Let me know.
– Phanindra
Jul 2 '17 at 2:54
I dont think so. By using object as so I am letting bindActionCreators know that postBooks prop in this component should dispatch the postBooks action that I have imported from my bookActions module. I have used this format before with no problems.
– bbmhmmad
Jul 2 '17 at 3:56
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44865904%2fmapdispatchtoprops-not-working-props-empty-error-redux-action-is-not-a-functi%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Figured it out.
So I was exporting component up top and export default below.
Noticed webpack was giving an error 'import and export may only appear at top level'. Went ahead and removed top export and now works as expected.
1
I'm glad it's working for you now, but I don't think that was actually your issue. the difference betweenexport class BooksForm ...
andexport default connect
is one is imported in another file usingimport { BooksForm } from './BooksForm'
and the other isimport BooksForm from './BooksForm'
(notice the brackets). The way you were exporting was fine, and is often done that way for testing purposes. The webpack error is more likely related to an error in your babel config.
– Michael Peyper
Jul 2 '17 at 11:39
I aslo removed my export from Class line and rebuilt my project, react native. Works now. Thanka.
– Hesam
Nov 18 '17 at 23:18
add a comment |
Figured it out.
So I was exporting component up top and export default below.
Noticed webpack was giving an error 'import and export may only appear at top level'. Went ahead and removed top export and now works as expected.
1
I'm glad it's working for you now, but I don't think that was actually your issue. the difference betweenexport class BooksForm ...
andexport default connect
is one is imported in another file usingimport { BooksForm } from './BooksForm'
and the other isimport BooksForm from './BooksForm'
(notice the brackets). The way you were exporting was fine, and is often done that way for testing purposes. The webpack error is more likely related to an error in your babel config.
– Michael Peyper
Jul 2 '17 at 11:39
I aslo removed my export from Class line and rebuilt my project, react native. Works now. Thanka.
– Hesam
Nov 18 '17 at 23:18
add a comment |
Figured it out.
So I was exporting component up top and export default below.
Noticed webpack was giving an error 'import and export may only appear at top level'. Went ahead and removed top export and now works as expected.
Figured it out.
So I was exporting component up top and export default below.
Noticed webpack was giving an error 'import and export may only appear at top level'. Went ahead and removed top export and now works as expected.
answered Jul 2 '17 at 11:12
bbmhmmadbbmhmmad
71110
71110
1
I'm glad it's working for you now, but I don't think that was actually your issue. the difference betweenexport class BooksForm ...
andexport default connect
is one is imported in another file usingimport { BooksForm } from './BooksForm'
and the other isimport BooksForm from './BooksForm'
(notice the brackets). The way you were exporting was fine, and is often done that way for testing purposes. The webpack error is more likely related to an error in your babel config.
– Michael Peyper
Jul 2 '17 at 11:39
I aslo removed my export from Class line and rebuilt my project, react native. Works now. Thanka.
– Hesam
Nov 18 '17 at 23:18
add a comment |
1
I'm glad it's working for you now, but I don't think that was actually your issue. the difference betweenexport class BooksForm ...
andexport default connect
is one is imported in another file usingimport { BooksForm } from './BooksForm'
and the other isimport BooksForm from './BooksForm'
(notice the brackets). The way you were exporting was fine, and is often done that way for testing purposes. The webpack error is more likely related to an error in your babel config.
– Michael Peyper
Jul 2 '17 at 11:39
I aslo removed my export from Class line and rebuilt my project, react native. Works now. Thanka.
– Hesam
Nov 18 '17 at 23:18
1
1
I'm glad it's working for you now, but I don't think that was actually your issue. the difference between
export class BooksForm ...
and export default connect
is one is imported in another file using import { BooksForm } from './BooksForm'
and the other is import BooksForm from './BooksForm'
(notice the brackets). The way you were exporting was fine, and is often done that way for testing purposes. The webpack error is more likely related to an error in your babel config.– Michael Peyper
Jul 2 '17 at 11:39
I'm glad it's working for you now, but I don't think that was actually your issue. the difference between
export class BooksForm ...
and export default connect
is one is imported in another file using import { BooksForm } from './BooksForm'
and the other is import BooksForm from './BooksForm'
(notice the brackets). The way you were exporting was fine, and is often done that way for testing purposes. The webpack error is more likely related to an error in your babel config.– Michael Peyper
Jul 2 '17 at 11:39
I aslo removed my export from Class line and rebuilt my project, react native. Works now. Thanka.
– Hesam
Nov 18 '17 at 23:18
I aslo removed my export from Class line and rebuilt my project, react native. Works now. Thanka.
– Hesam
Nov 18 '17 at 23:18
add a comment |
Faced the same issue and I just removed the curly braces from import
:
From
import {AppTest} from "./AppTest";
To
import AppTest from "./AppTest";
And that seemed to fixed the issue. Note that I had "export default" in my class already.
add a comment |
Faced the same issue and I just removed the curly braces from import
:
From
import {AppTest} from "./AppTest";
To
import AppTest from "./AppTest";
And that seemed to fixed the issue. Note that I had "export default" in my class already.
add a comment |
Faced the same issue and I just removed the curly braces from import
:
From
import {AppTest} from "./AppTest";
To
import AppTest from "./AppTest";
And that seemed to fixed the issue. Note that I had "export default" in my class already.
Faced the same issue and I just removed the curly braces from import
:
From
import {AppTest} from "./AppTest";
To
import AppTest from "./AppTest";
And that seemed to fixed the issue. Note that I had "export default" in my class already.
edited Feb 7 at 12:29
Nate
6,71512030
6,71512030
answered May 18 '18 at 3:35
mezziemezzie
1,099611
1,099611
add a comment |
add a comment |
So I had this same issue & the problem was the same as shown in the other useful answers but I will try to explain why this happens in more details
If we define the class with a default export & a named export as shown here (based on the question):
// named export
export class BooksForm extends React.Component{
.......
function mapDispatchToProps(dispatch){
return bindActionCreators({postBooks},dispatch)
}
// default export
export default connect(null,mapDispatchToProps)(BooksForm);
Then we have to be careful when importing the class to import the default export not the named export:
This imports the default export & shall work correctly with redux
import BooksForm from "./thePath"
This imports the named export & won't work with redux
import { BooksForm } from "./thePath"
If we define the two imports in the same class (which is usually done to make unit testing easier) :
Then we have to import the default export when rendering the component in order to use the redux connect() higher order function that we have exported.
Sometimes if you just depend on the editor autoimport, it will import the named export (which doesn't have the redux connect) & therefore will give that error
Bottom line
You don't have to remove any of the 2 exports, just import the default export (without braces) to use redux connect() correctly
add a comment |
So I had this same issue & the problem was the same as shown in the other useful answers but I will try to explain why this happens in more details
If we define the class with a default export & a named export as shown here (based on the question):
// named export
export class BooksForm extends React.Component{
.......
function mapDispatchToProps(dispatch){
return bindActionCreators({postBooks},dispatch)
}
// default export
export default connect(null,mapDispatchToProps)(BooksForm);
Then we have to be careful when importing the class to import the default export not the named export:
This imports the default export & shall work correctly with redux
import BooksForm from "./thePath"
This imports the named export & won't work with redux
import { BooksForm } from "./thePath"
If we define the two imports in the same class (which is usually done to make unit testing easier) :
Then we have to import the default export when rendering the component in order to use the redux connect() higher order function that we have exported.
Sometimes if you just depend on the editor autoimport, it will import the named export (which doesn't have the redux connect) & therefore will give that error
Bottom line
You don't have to remove any of the 2 exports, just import the default export (without braces) to use redux connect() correctly
add a comment |
So I had this same issue & the problem was the same as shown in the other useful answers but I will try to explain why this happens in more details
If we define the class with a default export & a named export as shown here (based on the question):
// named export
export class BooksForm extends React.Component{
.......
function mapDispatchToProps(dispatch){
return bindActionCreators({postBooks},dispatch)
}
// default export
export default connect(null,mapDispatchToProps)(BooksForm);
Then we have to be careful when importing the class to import the default export not the named export:
This imports the default export & shall work correctly with redux
import BooksForm from "./thePath"
This imports the named export & won't work with redux
import { BooksForm } from "./thePath"
If we define the two imports in the same class (which is usually done to make unit testing easier) :
Then we have to import the default export when rendering the component in order to use the redux connect() higher order function that we have exported.
Sometimes if you just depend on the editor autoimport, it will import the named export (which doesn't have the redux connect) & therefore will give that error
Bottom line
You don't have to remove any of the 2 exports, just import the default export (without braces) to use redux connect() correctly
So I had this same issue & the problem was the same as shown in the other useful answers but I will try to explain why this happens in more details
If we define the class with a default export & a named export as shown here (based on the question):
// named export
export class BooksForm extends React.Component{
.......
function mapDispatchToProps(dispatch){
return bindActionCreators({postBooks},dispatch)
}
// default export
export default connect(null,mapDispatchToProps)(BooksForm);
Then we have to be careful when importing the class to import the default export not the named export:
This imports the default export & shall work correctly with redux
import BooksForm from "./thePath"
This imports the named export & won't work with redux
import { BooksForm } from "./thePath"
If we define the two imports in the same class (which is usually done to make unit testing easier) :
Then we have to import the default export when rendering the component in order to use the redux connect() higher order function that we have exported.
Sometimes if you just depend on the editor autoimport, it will import the named export (which doesn't have the redux connect) & therefore will give that error
Bottom line
You don't have to remove any of the 2 exports, just import the default export (without braces) to use redux connect() correctly
answered Nov 26 '18 at 23:51
Ahmed ElkoussyAhmed Elkoussy
1,67021135
1,67021135
add a comment |
add a comment |
Please try again after importing the redux store. Let me know if that worked or not.And also using refs is not recommended. https://facebook.github.io/react/docs/refs-and-the-dom.html
It didnt work...
– bbmhmmad
Jul 2 '17 at 1:52
Take the curly braces around postBooks inside the bindActionCreators. The action creator should be a function, you gave it an object. I guess that's the problem. Let me know.
– Phanindra
Jul 2 '17 at 2:54
I dont think so. By using object as so I am letting bindActionCreators know that postBooks prop in this component should dispatch the postBooks action that I have imported from my bookActions module. I have used this format before with no problems.
– bbmhmmad
Jul 2 '17 at 3:56
add a comment |
Please try again after importing the redux store. Let me know if that worked or not.And also using refs is not recommended. https://facebook.github.io/react/docs/refs-and-the-dom.html
It didnt work...
– bbmhmmad
Jul 2 '17 at 1:52
Take the curly braces around postBooks inside the bindActionCreators. The action creator should be a function, you gave it an object. I guess that's the problem. Let me know.
– Phanindra
Jul 2 '17 at 2:54
I dont think so. By using object as so I am letting bindActionCreators know that postBooks prop in this component should dispatch the postBooks action that I have imported from my bookActions module. I have used this format before with no problems.
– bbmhmmad
Jul 2 '17 at 3:56
add a comment |
Please try again after importing the redux store. Let me know if that worked or not.And also using refs is not recommended. https://facebook.github.io/react/docs/refs-and-the-dom.html
Please try again after importing the redux store. Let me know if that worked or not.And also using refs is not recommended. https://facebook.github.io/react/docs/refs-and-the-dom.html
answered Jul 2 '17 at 1:15
PhanindraPhanindra
12
12
It didnt work...
– bbmhmmad
Jul 2 '17 at 1:52
Take the curly braces around postBooks inside the bindActionCreators. The action creator should be a function, you gave it an object. I guess that's the problem. Let me know.
– Phanindra
Jul 2 '17 at 2:54
I dont think so. By using object as so I am letting bindActionCreators know that postBooks prop in this component should dispatch the postBooks action that I have imported from my bookActions module. I have used this format before with no problems.
– bbmhmmad
Jul 2 '17 at 3:56
add a comment |
It didnt work...
– bbmhmmad
Jul 2 '17 at 1:52
Take the curly braces around postBooks inside the bindActionCreators. The action creator should be a function, you gave it an object. I guess that's the problem. Let me know.
– Phanindra
Jul 2 '17 at 2:54
I dont think so. By using object as so I am letting bindActionCreators know that postBooks prop in this component should dispatch the postBooks action that I have imported from my bookActions module. I have used this format before with no problems.
– bbmhmmad
Jul 2 '17 at 3:56
It didnt work...
– bbmhmmad
Jul 2 '17 at 1:52
It didnt work...
– bbmhmmad
Jul 2 '17 at 1:52
Take the curly braces around postBooks inside the bindActionCreators. The action creator should be a function, you gave it an object. I guess that's the problem. Let me know.
– Phanindra
Jul 2 '17 at 2:54
Take the curly braces around postBooks inside the bindActionCreators. The action creator should be a function, you gave it an object. I guess that's the problem. Let me know.
– Phanindra
Jul 2 '17 at 2:54
I dont think so. By using object as so I am letting bindActionCreators know that postBooks prop in this component should dispatch the postBooks action that I have imported from my bookActions module. I have used this format before with no problems.
– bbmhmmad
Jul 2 '17 at 3:56
I dont think so. By using object as so I am letting bindActionCreators know that postBooks prop in this component should dispatch the postBooks action that I have imported from my bookActions module. I have used this format before with no problems.
– bbmhmmad
Jul 2 '17 at 3:56
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44865904%2fmapdispatchtoprops-not-working-props-empty-error-redux-action-is-not-a-functi%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can we see the
mapDispatchToProps
code?– Li357
Jul 1 '17 at 22:30
If I understand you correctly, the mapDispatchToProps function is at the bottom of the component code.
– bbmhmmad
Jul 1 '17 at 23:28