logoESLint React
Rules

no-missing-context-display-name

Enforces that all contexts have a 'displayName' that can be used in DevTools.

Full Name in eslint-plugin-react-x

react-x/no-missing-context-display-name

Full Name in @eslint-react/eslint-plugin

@eslint-react/no-missing-context-display-name

Features

🔧

Presets

Rule Details

Context displayName property is used by React DevTools to identify the context in the component tree. Without it, debugging becomes difficult as contexts appear as "Context" or "Context.Provider" without any distinguishing information.

Common Violations

Invalid

import React from "react";

const MyContext = React.createContext();

Valid

import React from "react";

const MyContext = React.createContext();
MyContext.displayName = "MyContext";

Resources

Further Reading


See Also

On this page