Skip to content

[Bug]: jsx-no-constructed-context-values doesn't detect issues when context is used as provider in react v19 #3888

Closed
@andrew-pledge-io

Description

@andrew-pledge-io

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

Description Overview

In React 19, you can render <Context> as a provider instead of <Context.Provider>.

However when doing so jsx-no-constructed-context-values doesn't detect violations.

const MyContext = createContext();

function MyComponent(props) {
  return (<>
    {/* old style - violation detected */ }
    <MyContext.Provider value={{ hello: 'world' }} />
    
    {/* react 19 style - no violation */ }
    <MyContext value={{ hello: 'world' }} />
  </>);
}

Expected Behavior

eslint-plugin-react version

v7.37.2

eslint version

v8.57.1

node version

v18.20.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions