daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component, createContext } from 'react';
  2.  
  3. export const AppContext = createContext();
  4.  
  5. export class AppProvider extends Component {
  6.  
  7. state = {
  8.     test: '',
  9. };
  10.  
  11. getEntries() {
  12.     console.log('FIRED');
  13.  
  14.     this.setState({test: 'HELLO'});
  15. }
  16.  
  17. render() {
  18.     return (
  19.       <AppContext.Provider
  20.           value={{
  21.               ...this.state,
  22.               getEntries: this.getEntries
  23.           }}
  24.       >
  25.           {this.props.children}
  26.       </AppContext.Provider>
  27.     );
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top