{"size": 737, "ext": "js", "max_stars_repo_path": "client/src/utils/context/UserContext.js", "max_stars_repo_name": "Opyet/central-e-bookshop", "max_stars_repo_stars_event_min_datetime": "2021-09-01T20:45:33.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-06T22:27:19.000Z", "max_issues_repo_path": "client/src/utils/context/UserContext.js", "max_issues_repo_name": "Opyet/central-e-bookshop", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/src/utils/context/UserContext.js", "max_forks_repo_name": "Opyet/central-e-bookshop", "max_forks_repo_forks_event_min_datetime": "2022-01-29T20:55:49.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-29T20:55:49.000Z"}
{"max_stars_count": 6, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 23.03125, "max_line_length": 79, "alphanum_fraction": 0.4952510176}
import React, { Component } from 'react';

export const UserContext = React.createContext();

export class MyProvider extends Component{
    constructor(props){
        super(props);
        this.state = {
            iaAuthorized: false,
            accounts: null,
            web3: null,
            contract: null
        }
    }

    updateContext = (key, value)=>{
        this.setState((prevState)=>(
            {...prevState, [key]: value}
        ));        
    }

    render(){
        return(            
            <UserContext.Provider
                value={{state: this.state, updateContext: this.updateContext}}>
                {this.props.children}
            </UserContext.Provider>            
        )
    }
}

