Skip to content

Instantly share code, notes, and snippets.

@kevinnls
Last active June 21, 2020 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinnls/7fa2ed36da715e3b75aa31befd5de42d to your computer and use it in GitHub Desktop.
Save kevinnls/7fa2ed36da715e3b75aa31befd5de42d to your computer and use it in GitHub Desktop.

source (scroll down a bit)

import React from 'react';
 
const FirebaseContext = React.createContext(null);
 
export const withFirebase = Component => props => (
  <FirebaseContext.Consumer>
    {firebase => <Component {...props} firebase={firebase} />}
  </FirebaseContext.Consumer>
);
 
export default FirebaseContext;

===============================================================

expanding RHS of const withFirebase:

export const withFirebase = 
  function anon1 (Component) {
    { function anon2 (props) {
      <FirebaseContext.Consumer>
        {firebase => <Component {...props} firebase={firebase} />}
      </FirebaseContext.Consumer>
     }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment