this.props.dispatch is not a function in react with redux










0















I am calling api with redux action, so i created the reducers, action and store. But when i calling the redux action from the view part. I am getting the following error.




this.props.dispatch is not a function




Below is my reducer, actions and view part(React) Code which can help you to understand the code.



Note: when i console.log(this.props), I am not getting dispatch() function.



actions.js



import 
FETCH_WORKS_SUCCESS,
FETCH_WORKS_FAILURE
from './actionTypes'

export function fetchFeaturedWork()
return dispatch =>
return fetch("https://api.com/api/wp-json/customapi/all_posts?category=work&featured=true")
.then(res => res.json())
.then(json =>
dispatch(fetchFeaturedWorkSuccess(json.works));
return json.works;
)
;


export const fetchFeaturedWorkSuccess = works => (
type: FETCH_WORKS_SUCCESS,
payload: works
);


reducer.js



import 
OPEN_MENU,
CLOSE_MENU,
SET_DEVICE_TYPE,
FETCH_WORKS_SUCCESS,
FETCH_WORKS_FAILURE
from '../actions/actionTypes'

const initialState =
isMenuOpen: null,
isMobile: false,
error:null,
works:


const reducer = (state = initialState, action) =>
switch (action.type)
case OPEN_MENU:
return ...state, isMenuOpen: true
case CLOSE_MENU:
return ...state, isMenuOpen: false
case SET_DEVICE_TYPE:
return ...state, isMobile: action.isMobile
case FETCH_WORKS_SUCCESS:
return ...state,works:action.payload.works
case FETCH_WORKS_FAILURE:
return ...state,error:action.payload.error,works:
default:
return state



export default reducer;


store.js



import createStore, applyMiddleware from 'redux';
import rootReducer from './reducers/reducer';
import thunk from "redux-thunk";

let store = createStore(rootReducer,applyMiddleware(thunk))
export default store


App.js



import React, Component from 'react';
import Link from 'react-router-dom';
import Slider from "react-slick";
import Footer from '../footer'
import './index.css';
import connect from 'react-redux'
import openMenu,fetchFeaturedWork from '../../actions/actionCreators'
import Header from '../header'
import arrowRight from '../../images/arrow-right.svg'
import arrowLeft from '../../images/arrow-left.svg'

const mapStateToProps = (state) => (
isMobile: state && state.isMobile
)

const mapDispatchToProps = (dispatch, ownProps) => (
openMenu: (isMobile) => dispatch(openMenu(ownProps.isMobile))
)

class Work extends Component
getImgSlider = (slider) =>
this.imgSlider = slider

getTextSlider = (slider) =>
this.textSlider = slider

componentDidMount()
this.props.dispatch(fetchFeaturedWork());


render()
let className = 'idz_work'
if (this.props.isMobile)
className = 'idle'

return (
<div>

this.props.isMobile ?
null
:
<Link to='/home'>
<div className='idz_sidebar' style= left: 0 >
<div>
<label>FEATURED</label>
</div>
</div>
</Link>

<div className=className>
!this.props.isMobile &&
<Header logo="dark"/>

<div className="content">
<label className="light-gray" style=this.props.isMobile ? fontSize: '1.3rem' : fontSize: '2rem' >Featured Works</label>
<hr style=this.props.isMobile ? marginBottom: '0.5rem', marginTop: '0.5rem' : />
<hr style=this.props.isMobile ? marginBottom: '0.5rem', marginTop: '0.5rem' : />
<label className="light-gray" style=this.props.isMobile ? fontSize: '1.3rem' : fontSize: '2rem' >All Works</label>
<hr style=this.props.isMobile ? marginBottom: '0.5rem', marginTop: '0.5rem' : />
<hr />
</div>
this.props.isMobile ? null : <Footer />
</div>
</div>
);



export default connect(mapStateToProps, mapDispatchToProps)(Work);









share|improve this question
























  • Possible Duplicate of React Redux mapDispatchToProps vs this.props.dispatch or How does connect work without mapDispatchToProps

    – Shubham Khatri
    Nov 14 '18 at 6:08











  • Possible duplicate of React Redux mapDispatchToProps vs this.props.dispatch

    – vijayst
    Nov 14 '18 at 6:14















0















I am calling api with redux action, so i created the reducers, action and store. But when i calling the redux action from the view part. I am getting the following error.




this.props.dispatch is not a function




Below is my reducer, actions and view part(React) Code which can help you to understand the code.



Note: when i console.log(this.props), I am not getting dispatch() function.



actions.js



import 
FETCH_WORKS_SUCCESS,
FETCH_WORKS_FAILURE
from './actionTypes'

export function fetchFeaturedWork()
return dispatch =>
return fetch("https://api.com/api/wp-json/customapi/all_posts?category=work&featured=true")
.then(res => res.json())
.then(json =>
dispatch(fetchFeaturedWorkSuccess(json.works));
return json.works;
)
;


export const fetchFeaturedWorkSuccess = works => (
type: FETCH_WORKS_SUCCESS,
payload: works
);


reducer.js



import 
OPEN_MENU,
CLOSE_MENU,
SET_DEVICE_TYPE,
FETCH_WORKS_SUCCESS,
FETCH_WORKS_FAILURE
from '../actions/actionTypes'

const initialState =
isMenuOpen: null,
isMobile: false,
error:null,
works:


const reducer = (state = initialState, action) =>
switch (action.type)
case OPEN_MENU:
return ...state, isMenuOpen: true
case CLOSE_MENU:
return ...state, isMenuOpen: false
case SET_DEVICE_TYPE:
return ...state, isMobile: action.isMobile
case FETCH_WORKS_SUCCESS:
return ...state,works:action.payload.works
case FETCH_WORKS_FAILURE:
return ...state,error:action.payload.error,works:
default:
return state



export default reducer;


store.js



import createStore, applyMiddleware from 'redux';
import rootReducer from './reducers/reducer';
import thunk from "redux-thunk";

let store = createStore(rootReducer,applyMiddleware(thunk))
export default store


App.js



import React, Component from 'react';
import Link from 'react-router-dom';
import Slider from "react-slick";
import Footer from '../footer'
import './index.css';
import connect from 'react-redux'
import openMenu,fetchFeaturedWork from '../../actions/actionCreators'
import Header from '../header'
import arrowRight from '../../images/arrow-right.svg'
import arrowLeft from '../../images/arrow-left.svg'

const mapStateToProps = (state) => (
isMobile: state && state.isMobile
)

const mapDispatchToProps = (dispatch, ownProps) => (
openMenu: (isMobile) => dispatch(openMenu(ownProps.isMobile))
)

class Work extends Component
getImgSlider = (slider) =>
this.imgSlider = slider

getTextSlider = (slider) =>
this.textSlider = slider

componentDidMount()
this.props.dispatch(fetchFeaturedWork());


render()
let className = 'idz_work'
if (this.props.isMobile)
className = 'idle'

return (
<div>

this.props.isMobile ?
null
:
<Link to='/home'>
<div className='idz_sidebar' style= left: 0 >
<div>
<label>FEATURED</label>
</div>
</div>
</Link>

<div className=className>
!this.props.isMobile &&
<Header logo="dark"/>

<div className="content">
<label className="light-gray" style=this.props.isMobile ? fontSize: '1.3rem' : fontSize: '2rem' >Featured Works</label>
<hr style=this.props.isMobile ? marginBottom: '0.5rem', marginTop: '0.5rem' : />
<hr style=this.props.isMobile ? marginBottom: '0.5rem', marginTop: '0.5rem' : />
<label className="light-gray" style=this.props.isMobile ? fontSize: '1.3rem' : fontSize: '2rem' >All Works</label>
<hr style=this.props.isMobile ? marginBottom: '0.5rem', marginTop: '0.5rem' : />
<hr />
</div>
this.props.isMobile ? null : <Footer />
</div>
</div>
);



export default connect(mapStateToProps, mapDispatchToProps)(Work);









share|improve this question
























  • Possible Duplicate of React Redux mapDispatchToProps vs this.props.dispatch or How does connect work without mapDispatchToProps

    – Shubham Khatri
    Nov 14 '18 at 6:08











  • Possible duplicate of React Redux mapDispatchToProps vs this.props.dispatch

    – vijayst
    Nov 14 '18 at 6:14













0












0








0








I am calling api with redux action, so i created the reducers, action and store. But when i calling the redux action from the view part. I am getting the following error.




this.props.dispatch is not a function




Below is my reducer, actions and view part(React) Code which can help you to understand the code.



Note: when i console.log(this.props), I am not getting dispatch() function.



actions.js



import 
FETCH_WORKS_SUCCESS,
FETCH_WORKS_FAILURE
from './actionTypes'

export function fetchFeaturedWork()
return dispatch =>
return fetch("https://api.com/api/wp-json/customapi/all_posts?category=work&featured=true")
.then(res => res.json())
.then(json =>
dispatch(fetchFeaturedWorkSuccess(json.works));
return json.works;
)
;


export const fetchFeaturedWorkSuccess = works => (
type: FETCH_WORKS_SUCCESS,
payload: works
);


reducer.js



import 
OPEN_MENU,
CLOSE_MENU,
SET_DEVICE_TYPE,
FETCH_WORKS_SUCCESS,
FETCH_WORKS_FAILURE
from '../actions/actionTypes'

const initialState =
isMenuOpen: null,
isMobile: false,
error:null,
works:


const reducer = (state = initialState, action) =>
switch (action.type)
case OPEN_MENU:
return ...state, isMenuOpen: true
case CLOSE_MENU:
return ...state, isMenuOpen: false
case SET_DEVICE_TYPE:
return ...state, isMobile: action.isMobile
case FETCH_WORKS_SUCCESS:
return ...state,works:action.payload.works
case FETCH_WORKS_FAILURE:
return ...state,error:action.payload.error,works:
default:
return state



export default reducer;


store.js



import createStore, applyMiddleware from 'redux';
import rootReducer from './reducers/reducer';
import thunk from "redux-thunk";

let store = createStore(rootReducer,applyMiddleware(thunk))
export default store


App.js



import React, Component from 'react';
import Link from 'react-router-dom';
import Slider from "react-slick";
import Footer from '../footer'
import './index.css';
import connect from 'react-redux'
import openMenu,fetchFeaturedWork from '../../actions/actionCreators'
import Header from '../header'
import arrowRight from '../../images/arrow-right.svg'
import arrowLeft from '../../images/arrow-left.svg'

const mapStateToProps = (state) => (
isMobile: state && state.isMobile
)

const mapDispatchToProps = (dispatch, ownProps) => (
openMenu: (isMobile) => dispatch(openMenu(ownProps.isMobile))
)

class Work extends Component
getImgSlider = (slider) =>
this.imgSlider = slider

getTextSlider = (slider) =>
this.textSlider = slider

componentDidMount()
this.props.dispatch(fetchFeaturedWork());


render()
let className = 'idz_work'
if (this.props.isMobile)
className = 'idle'

return (
<div>

this.props.isMobile ?
null
:
<Link to='/home'>
<div className='idz_sidebar' style= left: 0 >
<div>
<label>FEATURED</label>
</div>
</div>
</Link>

<div className=className>
!this.props.isMobile &&
<Header logo="dark"/>

<div className="content">
<label className="light-gray" style=this.props.isMobile ? fontSize: '1.3rem' : fontSize: '2rem' >Featured Works</label>
<hr style=this.props.isMobile ? marginBottom: '0.5rem', marginTop: '0.5rem' : />
<hr style=this.props.isMobile ? marginBottom: '0.5rem', marginTop: '0.5rem' : />
<label className="light-gray" style=this.props.isMobile ? fontSize: '1.3rem' : fontSize: '2rem' >All Works</label>
<hr style=this.props.isMobile ? marginBottom: '0.5rem', marginTop: '0.5rem' : />
<hr />
</div>
this.props.isMobile ? null : <Footer />
</div>
</div>
);



export default connect(mapStateToProps, mapDispatchToProps)(Work);









share|improve this question
















I am calling api with redux action, so i created the reducers, action and store. But when i calling the redux action from the view part. I am getting the following error.




this.props.dispatch is not a function




Below is my reducer, actions and view part(React) Code which can help you to understand the code.



Note: when i console.log(this.props), I am not getting dispatch() function.



actions.js



import 
FETCH_WORKS_SUCCESS,
FETCH_WORKS_FAILURE
from './actionTypes'

export function fetchFeaturedWork()
return dispatch =>
return fetch("https://api.com/api/wp-json/customapi/all_posts?category=work&featured=true")
.then(res => res.json())
.then(json =>
dispatch(fetchFeaturedWorkSuccess(json.works));
return json.works;
)
;


export const fetchFeaturedWorkSuccess = works => (
type: FETCH_WORKS_SUCCESS,
payload: works
);


reducer.js



import 
OPEN_MENU,
CLOSE_MENU,
SET_DEVICE_TYPE,
FETCH_WORKS_SUCCESS,
FETCH_WORKS_FAILURE
from '../actions/actionTypes'

const initialState =
isMenuOpen: null,
isMobile: false,
error:null,
works:


const reducer = (state = initialState, action) =>
switch (action.type)
case OPEN_MENU:
return ...state, isMenuOpen: true
case CLOSE_MENU:
return ...state, isMenuOpen: false
case SET_DEVICE_TYPE:
return ...state, isMobile: action.isMobile
case FETCH_WORKS_SUCCESS:
return ...state,works:action.payload.works
case FETCH_WORKS_FAILURE:
return ...state,error:action.payload.error,works:
default:
return state



export default reducer;


store.js



import createStore, applyMiddleware from 'redux';
import rootReducer from './reducers/reducer';
import thunk from "redux-thunk";

let store = createStore(rootReducer,applyMiddleware(thunk))
export default store


App.js



import React, Component from 'react';
import Link from 'react-router-dom';
import Slider from "react-slick";
import Footer from '../footer'
import './index.css';
import connect from 'react-redux'
import openMenu,fetchFeaturedWork from '../../actions/actionCreators'
import Header from '../header'
import arrowRight from '../../images/arrow-right.svg'
import arrowLeft from '../../images/arrow-left.svg'

const mapStateToProps = (state) => (
isMobile: state && state.isMobile
)

const mapDispatchToProps = (dispatch, ownProps) => (
openMenu: (isMobile) => dispatch(openMenu(ownProps.isMobile))
)

class Work extends Component
getImgSlider = (slider) =>
this.imgSlider = slider

getTextSlider = (slider) =>
this.textSlider = slider

componentDidMount()
this.props.dispatch(fetchFeaturedWork());


render()
let className = 'idz_work'
if (this.props.isMobile)
className = 'idle'

return (
<div>

this.props.isMobile ?
null
:
<Link to='/home'>
<div className='idz_sidebar' style= left: 0 >
<div>
<label>FEATURED</label>
</div>
</div>
</Link>

<div className=className>
!this.props.isMobile &&
<Header logo="dark"/>

<div className="content">
<label className="light-gray" style=this.props.isMobile ? fontSize: '1.3rem' : fontSize: '2rem' >Featured Works</label>
<hr style=this.props.isMobile ? marginBottom: '0.5rem', marginTop: '0.5rem' : />
<hr style=this.props.isMobile ? marginBottom: '0.5rem', marginTop: '0.5rem' : />
<label className="light-gray" style=this.props.isMobile ? fontSize: '1.3rem' : fontSize: '2rem' >All Works</label>
<hr style=this.props.isMobile ? marginBottom: '0.5rem', marginTop: '0.5rem' : />
<hr />
</div>
this.props.isMobile ? null : <Footer />
</div>
</div>
);



export default connect(mapStateToProps, mapDispatchToProps)(Work);






javascript reactjs redux






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 6:35

























asked Nov 14 '18 at 5:48







user10298495



















  • Possible Duplicate of React Redux mapDispatchToProps vs this.props.dispatch or How does connect work without mapDispatchToProps

    – Shubham Khatri
    Nov 14 '18 at 6:08











  • Possible duplicate of React Redux mapDispatchToProps vs this.props.dispatch

    – vijayst
    Nov 14 '18 at 6:14

















  • Possible Duplicate of React Redux mapDispatchToProps vs this.props.dispatch or How does connect work without mapDispatchToProps

    – Shubham Khatri
    Nov 14 '18 at 6:08











  • Possible duplicate of React Redux mapDispatchToProps vs this.props.dispatch

    – vijayst
    Nov 14 '18 at 6:14
















Possible Duplicate of React Redux mapDispatchToProps vs this.props.dispatch or How does connect work without mapDispatchToProps

– Shubham Khatri
Nov 14 '18 at 6:08





Possible Duplicate of React Redux mapDispatchToProps vs this.props.dispatch or How does connect work without mapDispatchToProps

– Shubham Khatri
Nov 14 '18 at 6:08













Possible duplicate of React Redux mapDispatchToProps vs this.props.dispatch

– vijayst
Nov 14 '18 at 6:14





Possible duplicate of React Redux mapDispatchToProps vs this.props.dispatch

– vijayst
Nov 14 '18 at 6:14












1 Answer
1






active

oldest

votes


















0














When you use mapDispatchToProps, dispatch is not longer available in props. So, either get rid of mapDispatchToProps and use this.props.dispatch. Or move all dispatch functions to mapDispatchToProps.






share|improve this answer























  • actually i don't know functionality of mapDispatchToProps. Can you please explain me what it is? and you can see, I used the this.props.dispatch and getting the error "this.props.dispatch is not a function"

    – user10298495
    Nov 14 '18 at 5:59












  • It defines a prop (of function type) to dispatch an action to the store. From your code, openMenu: (isMobile) => dispatch(openMenu(ownProps.isMobile)), openMenu is the function prop that you have defined. It dispatches an action - openMenu() to the store. The result of openMenu() is an action.

    – vijayst
    Nov 14 '18 at 6:03











  • so what i need to do now to solve the error?

    – user10298495
    Nov 14 '18 at 6:08











  • move this.props.dispatch(fetchFeaturedWork()); to mapDispatchToProps just like the other function you have there.

    – vijayst
    Nov 14 '18 at 6:10











  • I have done but getting the error. can you please edit the code?

    – user10298495
    Nov 14 '18 at 6:11










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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53293891%2fthis-props-dispatch-is-not-a-function-in-react-with-redux%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown
























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














When you use mapDispatchToProps, dispatch is not longer available in props. So, either get rid of mapDispatchToProps and use this.props.dispatch. Or move all dispatch functions to mapDispatchToProps.






share|improve this answer























  • actually i don't know functionality of mapDispatchToProps. Can you please explain me what it is? and you can see, I used the this.props.dispatch and getting the error "this.props.dispatch is not a function"

    – user10298495
    Nov 14 '18 at 5:59












  • It defines a prop (of function type) to dispatch an action to the store. From your code, openMenu: (isMobile) => dispatch(openMenu(ownProps.isMobile)), openMenu is the function prop that you have defined. It dispatches an action - openMenu() to the store. The result of openMenu() is an action.

    – vijayst
    Nov 14 '18 at 6:03











  • so what i need to do now to solve the error?

    – user10298495
    Nov 14 '18 at 6:08











  • move this.props.dispatch(fetchFeaturedWork()); to mapDispatchToProps just like the other function you have there.

    – vijayst
    Nov 14 '18 at 6:10











  • I have done but getting the error. can you please edit the code?

    – user10298495
    Nov 14 '18 at 6:11















0














When you use mapDispatchToProps, dispatch is not longer available in props. So, either get rid of mapDispatchToProps and use this.props.dispatch. Or move all dispatch functions to mapDispatchToProps.






share|improve this answer























  • actually i don't know functionality of mapDispatchToProps. Can you please explain me what it is? and you can see, I used the this.props.dispatch and getting the error "this.props.dispatch is not a function"

    – user10298495
    Nov 14 '18 at 5:59












  • It defines a prop (of function type) to dispatch an action to the store. From your code, openMenu: (isMobile) => dispatch(openMenu(ownProps.isMobile)), openMenu is the function prop that you have defined. It dispatches an action - openMenu() to the store. The result of openMenu() is an action.

    – vijayst
    Nov 14 '18 at 6:03











  • so what i need to do now to solve the error?

    – user10298495
    Nov 14 '18 at 6:08











  • move this.props.dispatch(fetchFeaturedWork()); to mapDispatchToProps just like the other function you have there.

    – vijayst
    Nov 14 '18 at 6:10











  • I have done but getting the error. can you please edit the code?

    – user10298495
    Nov 14 '18 at 6:11













0












0








0







When you use mapDispatchToProps, dispatch is not longer available in props. So, either get rid of mapDispatchToProps and use this.props.dispatch. Or move all dispatch functions to mapDispatchToProps.






share|improve this answer













When you use mapDispatchToProps, dispatch is not longer available in props. So, either get rid of mapDispatchToProps and use this.props.dispatch. Or move all dispatch functions to mapDispatchToProps.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 5:58









vijaystvijayst

6,33893876




6,33893876












  • actually i don't know functionality of mapDispatchToProps. Can you please explain me what it is? and you can see, I used the this.props.dispatch and getting the error "this.props.dispatch is not a function"

    – user10298495
    Nov 14 '18 at 5:59












  • It defines a prop (of function type) to dispatch an action to the store. From your code, openMenu: (isMobile) => dispatch(openMenu(ownProps.isMobile)), openMenu is the function prop that you have defined. It dispatches an action - openMenu() to the store. The result of openMenu() is an action.

    – vijayst
    Nov 14 '18 at 6:03











  • so what i need to do now to solve the error?

    – user10298495
    Nov 14 '18 at 6:08











  • move this.props.dispatch(fetchFeaturedWork()); to mapDispatchToProps just like the other function you have there.

    – vijayst
    Nov 14 '18 at 6:10











  • I have done but getting the error. can you please edit the code?

    – user10298495
    Nov 14 '18 at 6:11

















  • actually i don't know functionality of mapDispatchToProps. Can you please explain me what it is? and you can see, I used the this.props.dispatch and getting the error "this.props.dispatch is not a function"

    – user10298495
    Nov 14 '18 at 5:59












  • It defines a prop (of function type) to dispatch an action to the store. From your code, openMenu: (isMobile) => dispatch(openMenu(ownProps.isMobile)), openMenu is the function prop that you have defined. It dispatches an action - openMenu() to the store. The result of openMenu() is an action.

    – vijayst
    Nov 14 '18 at 6:03











  • so what i need to do now to solve the error?

    – user10298495
    Nov 14 '18 at 6:08











  • move this.props.dispatch(fetchFeaturedWork()); to mapDispatchToProps just like the other function you have there.

    – vijayst
    Nov 14 '18 at 6:10











  • I have done but getting the error. can you please edit the code?

    – user10298495
    Nov 14 '18 at 6:11
















actually i don't know functionality of mapDispatchToProps. Can you please explain me what it is? and you can see, I used the this.props.dispatch and getting the error "this.props.dispatch is not a function"

– user10298495
Nov 14 '18 at 5:59






actually i don't know functionality of mapDispatchToProps. Can you please explain me what it is? and you can see, I used the this.props.dispatch and getting the error "this.props.dispatch is not a function"

– user10298495
Nov 14 '18 at 5:59














It defines a prop (of function type) to dispatch an action to the store. From your code, openMenu: (isMobile) => dispatch(openMenu(ownProps.isMobile)), openMenu is the function prop that you have defined. It dispatches an action - openMenu() to the store. The result of openMenu() is an action.

– vijayst
Nov 14 '18 at 6:03





It defines a prop (of function type) to dispatch an action to the store. From your code, openMenu: (isMobile) => dispatch(openMenu(ownProps.isMobile)), openMenu is the function prop that you have defined. It dispatches an action - openMenu() to the store. The result of openMenu() is an action.

– vijayst
Nov 14 '18 at 6:03













so what i need to do now to solve the error?

– user10298495
Nov 14 '18 at 6:08





so what i need to do now to solve the error?

– user10298495
Nov 14 '18 at 6:08













move this.props.dispatch(fetchFeaturedWork()); to mapDispatchToProps just like the other function you have there.

– vijayst
Nov 14 '18 at 6:10





move this.props.dispatch(fetchFeaturedWork()); to mapDispatchToProps just like the other function you have there.

– vijayst
Nov 14 '18 at 6:10













I have done but getting the error. can you please edit the code?

– user10298495
Nov 14 '18 at 6:11





I have done but getting the error. can you please edit the code?

– user10298495
Nov 14 '18 at 6:11



















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53293891%2fthis-props-dispatch-is-not-a-function-in-react-with-redux%23new-answer', 'question_page');

);

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







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo