Class components and migration

Class contextType

Assign a context object to a static field and read its nearest provider value through this.context.

Formal Syntax & Structure

react syntaxreact
static contextType = WorkshopContext;

Working Example

Example Snippetreact
static contextType = WorkshopContext;
React Reference