Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

261
Views
In React Redux I am dispatching twice to the store in one component but only one payload is being delivered to the store

I am working in React Native and sending payloads to my redux store: accessToken and firebase_userId after they have been retrieved.

They are sent using dispatch() in an useEffect() function.

When I log the state of my redux store though only the accessToken is being sent to the store and not the firebase_userId.

How can I dispatch both payloads at once from my component so they both are sent to my redux store?

Order of Operations:

User Log in --> retreives accessToken and firebase_userId --> state is set to both of these values --> useEffect() executes dispatching accessToken and firebase_userId to the redux store.

COMPONENT DISPATCHING accessToken and firebase_userId

const [accessToken, setAccessToken] = useState("");
const [firebase_userId, setFirebase_userId] = useState("");

const dispatch = useDispatch();

//listens for state of accessToken and firebase_userId to be set
useEffect(() => {
    dispatch({
      type: "access_token",
      payload: accessToken
    });
  }, [accessToken]);

  useEffect(() => {
    dispatch({
      type: "firebase_userId",
      payload: firebase_userId,
    });
  }, [firebase_userId]);


function onSignIn(){
...//Signs in to firebase and returns accessToken and firebase_userId

//set the state of the component with retrieved values

 setAccessToken(googleUser.accessToken);
 setFirebase_userId(result.user.uid);


}

REDUX STORE

import React from "react";
import symbolicateStackTrace from "react-native/Libraries/Core/Devtools/symbolicateStackTrace";
import { applyMiddleware, createStore } from "redux";
import thunk from "redux-thunk";

const initialState = {
  access_token: "",
  firebase_userId: "",
};

const counterReducer = (
  state = initialState,

  if (action.type === "access_token") {
   
    return {
      ...state,
      access_token: action.payload,
    };
  }

  if (action.type === "firebase_userId") {
   
   
    return {
      ...state,
      firebase_userId: action.payload,
    };
  }

  return state;
};

const store = createStore(counterReducer, applyMiddleware(thunk));

export default store;
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!