-
Notifications
You must be signed in to change notification settings - Fork 46.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to specify displayName for createContext() providers and consumers #12695
Labels
Comments
React can't "guess" the name from the declaring code but we should probably make it possible to specify |
gaearon
changed the title
Set correct displayNmae to Context
Allow to specify displayName for createContext() providers and consumers
Apr 26, 2018
Thanks 😃 |
@gaearon can I take this up? |
I think this is the paired React DevTools issue (facebook/react-devtools#1008) |
Context providers and consumers support a custom display in React DevTools like so: const ThemeContext = React.createContext("light");
ThemeContext.displayName = 'ThemeContext';
<ThemeContext.Provider> // "ThemeContext.Provider" in DevTools
<ThemeContext.Consumer> // "ThemeContext.Consumer" in DevTools |
facebook-github-bot
pushed a commit
to facebook/flow
that referenced
this issue
Jan 26, 2019
Summary: Related: facebook/react#12695 (comment) Context providers and consumers [support a custom display in React DevTools](https://github.com/facebook/react-devtools/blob/38fe9782f82fbcb4f6137e5b920147d35ebe1992/backend/attachRendererFiber.js#L362-L387) like so: ```js const ThemeContext = React.createContext("light"); ThemeContext.displayName = 'ThemeContext'; <ThemeContext.Provider> // "ThemeContext.Provider" in DevTools <ThemeContext.Consumer> // "ThemeContext.Consumer" in DevTools ``` cc jbrown215 Pull Request resolved: #7387 Reviewed By: bvaughn Differential Revision: D13792923 Pulled By: jbrown215 fbshipit-source-id: 28e9b51e1e740b5f7cad78edc5f056779a9ec8b1
This was referenced Jul 14, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you want to request a feature or report a bug?
bug
What is the current behavior?
in React tree name of a Context must be like its name in code
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
let's have a look at React tree in Chrome extention's page
here is Context - not MyContext
What is the expected behavior?
expexted to see MyContext
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
16.3.2
The text was updated successfully, but these errors were encountered: