mercredi 4 août 2021

UserConsumer (ContextAPI) doesnt run when i call it in function

So i am trying to call function of class at the other function. And i have to pass paramater that comes from context provider. But when i try to use in function to get data i need from context provider, it looks like program doesnt see that piece of code that includes . If you can help, i would be so happy.

componentDidMount = () => {      
        axios.post("http://localhost:8080/api/add_market_items").then(response=>{
            
           
                <UserConsumer>
                    {
                         value => {
                            console.log('====================================');
                            console.log("xxxxx");
                            console.log('====================================');
                            this.getMarketItems(value);
                         }
                    }
                </UserConsumer>
        
            
        })
        
    }



Aucun commentaire:

Enregistrer un commentaire