How to push data in object? Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How to push data in object? without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I’m using Redux in my React App, and I need to put data to object (using action).

I have such reducer and action:

        case GET_USER_DATA: {
            return {
                user: action.value // user - is object

//my action
        export const getUserData = (value) => ({type: 'GET_USER_DATA',value})

And then I need to put data to my Redux state using action, but it not works, can anybody explaine me how to do this?


    authListener() {
        fire.auth().onAuthStateChanged((user) => {
          if (user) {
            getUserData(user) // I need to put it here
            localStorage.setItem('user', user.uid);
          } else {


Have you added this function in mapDispatchToProps so that it can get the dispatch function and reducer can be called?

const mapStateToProps = (state: any) => {
    return {
        //any data from state

function mapDispatchToProps(dispatch: any) {
    return bindActionCreators({
    }, dispatch);

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

You can now call the function as

We are here to answer your question about How to push data in object? - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji