Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

v1.3.0

Latest
Compare
Choose a tag to compare
@adrianmcli adrianmcli released this 13 May 12:01
· 18 commits to develop since this release
d35c4d0

Context object, React Hooks, and Source Maps!

It's been a long time since we released a new version. This time, we are including the following:

  • #35 Adds source map for production
  • #46 Adds React Hooks support
  • #47 Context object now exported for easier usage with classes

Using Drizzle-React with class.contextType pattern

First you need to make sure that you wrap your App at the top-level with the DrizzleContext Provider:

<DrizzleContext.Provider drizzle={drizzle}>
  <MyApp />
</DrizzleContext.Provider>

Then, in any child class component:

import { DrizzleContext } from "drizzle-react";

class MyClass extends Component {
  render() {
    const { drizzle, drizzleState, initialized } = this.context;
    /* render something based on drizzle */
  }
}

MyClass.contextType = DrizzleContext.Context;

Or if you are using the experimental public class fields syntax:

import { DrizzleContext } from "drizzle-react";

class MyClass extends Component {
  static contextType = DrizzleContext.Context;
  render() {
    const { drizzle, drizzleState, initialized } = this.context;
    /* render something based on drizzle */
  }
}