Skip to content

Commit

Permalink
[core] Add displayName to contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Nov 20, 2019
1 parent 52c4451 commit 4ed3b88
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/src/modules/components/PageContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ const PageContext = React.createContext({
pages: [],
});

if (process.env.NODE_ENV !== 'production') {
PageContext.displayName = 'PageContext';
}

export default PageContext;
6 changes: 5 additions & 1 deletion docs/src/modules/components/ThemeContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ const highDensity = {
};

export const DispatchContext = React.createContext(() => {
throw new Error('Forgot to wrap component in ThemeContext.Provider');
throw new Error('Forgot to wrap component in `ThemeProvider`');
});

if (process.env.NODE_ENV !== 'production') {
DispatchContext.displayName = 'ThemeDispatchContext';
}

const useEnhancedEffect = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;

export function ThemeProvider(props) {
Expand Down
8 changes: 7 additions & 1 deletion packages/material-ui-lab/src/TreeView/TreeViewContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ import React from 'react';
/**
* @ignore - internal component.
*/
export default React.createContext({});
const TreeViewContext = React.createContext({});

if (process.env.NODE_ENV !== 'production') {
TreeViewContext.displayName = 'TreeViewContext';
}

export default TreeViewContext;
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const defaultOptions = {

export const StylesContext = React.createContext(defaultOptions);

if (process.env.NODE_ENV !== 'production') {
StylesContext.displayName = 'StylesContext';
}

let injectFirstNode;

function StylesProvider(props) {
Expand Down
4 changes: 4 additions & 0 deletions packages/material-ui-styles/src/useTheme/ThemeContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ import React from 'react';

const ThemeContext = React.createContext(null);

if (process.env.NODE_ENV !== 'production') {
ThemeContext.displayName = 'ThemeContext';
}

export default ThemeContext;
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ import React from 'react';
*/
const ExpansionPanelContext = React.createContext({});

if (process.env.NODE_ENV !== 'production') {
ExpansionPanelContext.displayName = 'ExpansionPanelContext';
}

export default ExpansionPanelContext;
4 changes: 4 additions & 0 deletions packages/material-ui/src/FormControl/FormControlContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import React from 'react';
*/
const FormControlContext = React.createContext();

if (process.env.NODE_ENV !== 'production') {
FormControlContext.displayName = 'FormControlContext';
}

export function useFormControl() {
return React.useContext(FormControlContext);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/material-ui/src/List/ListContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ import React from 'react';
*/
const ListContext = React.createContext({});

if (process.env.NODE_ENV !== 'production') {
ListContext.displayName = 'ListContext';
}

export default ListContext;
4 changes: 4 additions & 0 deletions packages/material-ui/src/RadioGroup/RadioGroupContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ import React from 'react';
*/
const RadioGroupContext = React.createContext();

if (process.env.NODE_ENV !== 'production') {
RadioGroupContext.displayName = 'RadioGroupContext';
}

export default RadioGroupContext;
4 changes: 4 additions & 0 deletions packages/material-ui/src/Table/TableContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ import React from 'react';
*/
const TableContext = React.createContext();

if (process.env.NODE_ENV !== 'production') {
TableContext.displayName = 'TableContext';
}

export default TableContext;
4 changes: 4 additions & 0 deletions packages/material-ui/src/Table/Tablelvl2Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ import React from 'react';
*/
const Tablelvl2Context = React.createContext();

if (process.env.NODE_ENV !== 'production') {
Tablelvl2Context.displayName = 'Tablelvl2Context';
}

export default Tablelvl2Context;
4 changes: 4 additions & 0 deletions packages/material-ui/src/test-utils/RenderMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import * as PropTypes from 'prop-types';

const Context = React.createContext();

if (process.env.NODE_ENV !== 'production') {
Context.displayName = 'RenderContext';
}

/**
* @ignore - internal component.
*/
Expand Down

0 comments on commit 4ed3b88

Please sign in to comment.