-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
this.props.dispatch is not a function. #6
Comments
` export default function configureStore(initialState) { This is the format of createStore i create, i believe it's no need to put the component (toast) into createStore |
@fahrurben hows your code different than what i have above ? Also the issue that i m facing is due to this,, I am stuck here, coz I want to use this toaster library via redux but when i do that I get the error message : this.props.dispatch is not a function. bla bla dispatch undefined. New code after usual componentwillmount() and navigation bla bla bla, But if i do need the actions too. the moment i add the following lines, It complains and you know why that complains, How to “ use the shortcut by passing an object directly to 'connect’. “ ? |
@fahrurben if i do as you suggested, i get the following error. My major concern is i cant call the Actions from with in the class componet. |
From the first i look, the problem are with reducers. Do you have combine the reducers with 'toast' Reducer ? You can't put the two reducer in Create store, instead combine the reducer first. |
It will need to check reducer, action, container, component to know the problem |
@fahrurben your right about : "From the first i look, the problem are with reducers. Do you have combine the reducers with 'toast' Reducer ? You can't put the two reducer in Create store, instead combine the reducer first." Ive provided you both the reduccer, action, component above. |
Actually i don't see any action to map to the container. |
Lol - yes it works fine if I don’t have any actions but the moment I try to use the actions it throws the errors.
…Sent from my iPhone
On Sep 29, 2017, at 12:42 AM, Farhrurrazi ***@***.***> wrote:
Actually i don't see any action to map to the container.
export default connect()(FollowupScreen);
will enough, if not i will need to see what 'actions' you put to component.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
So, maybe this is maybe help you.
Do you put the dispatch in returned object ? If not, maybe you can try it. I think this caused your issue. |
I want to use redux, ive been using the state in every component. |
function mapDispatchToProps(dispatch) { return { dispatch, onClick: () => dispatch(increment()) }; } where is increment() coming from ? |
and how do i wtite the last statement i.e export class ? |
Change onclick with your action/function to map, if none so no need to define this
|
this is what ive got , But it still cant access the Prioritiesfetch() in the componentWillMount import * as actions from '../actions'; componentWillMount(){ |
it should be |
In container const mapDispatchToProps = (dispatch) => { In your component constructor(props) {
} componentWillMount(){ |
this is great, constructor(props) { this.prioritiesFetch = props.prioritiesFetch; But how woudl you suggest to implment in the case where we want to import all the actions with one go ? ie import * as actions from '..actions'; |
@fahrurben so it worked for when i had only one action, I get error when i have more than 1 actions and ive to use the mapStateToProps, Here is my code, can you please explain what am I doing wrong const mapStateToProps = (state) => { const mapDispatchToProps = (dispatch) => { export default connect(mapStateToProps, mapDispatchToProps)(MyProfileScreen); const mapStateToProps = (state) => { const mapDispatchToProps = (dispatch) => { export default connect(mapStateToProps, mapDispatchToProps)(MyProfileScreen); |
@jpca999 Can you upload an example project with your code to github? I'll probably will be more helpful taking a closer look the entire code |
@sbalay hmm |
If action need parameter, it must provide in mapDispatchToProps const mapDispatchToProps = (dispatch) => { |
I was tryign to use this in the component but i got this error message, how do i fix it ?
I think th eissue is with the store coz Im using the redux-thunk, How can i fix it ?
Heres mycode :
import { createStore, compose, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import reducers from '../reducers';
const store = createStore(
reducers,
{},
compose (
applyMiddleware(thunk)
)
);
export default store;
//And my reducer code, is.
import { combineReducers } from 'redux';
import auth from './auth_reducer';
import jobs from './jobs_reducer';
// New
import LibraryReducer from './comps/LibraryReducer'
import SelectionReducer from './comps/SelectionReducer'
import { toastReducer as toast } from 'react-native-redux-toast';
export default combineReducers({
auth: auth,
jobs: jobs,
form: form,
libraries: LibraryReducer,
selectedLibraryId: SelectionReducer,
toast,
});
//
The text was updated successfully, but these errors were encountered: