This repository has been archived by the owner on Sep 27, 2019. It is now read-only.
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 */
}
}