Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/pages/api-docs/root-ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ function MyComponent() {
}
```

@deprecated



## Props
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
"size:why": "size-limit --why packages/material-ui/build/index.js",
"start": "yarn docs:dev",
"test": "yarn lint && yarn typescript && yarn test:coverage",
"test:coverage": "cross-env NODE_ENV=test BABEL_ENV=coverage nyc mocha 'packages/**/*.test.js' 'docs/**/*.test.js' --exclude '**/node_modules/**' && nyc report -r lcovonly",
"test:coverage:html": "cross-env NODE_ENV=test BABEL_ENV=coverage nyc mocha 'packages/**/**/*.test.js' --exclude '**/node_modules/**' && nyc report --reporter=html",
"test:karma": "cross-env NODE_ENV=test karma start test/karma.conf.js",
"test:coverage": "cross-env INTERNAL=true NODE_ENV=test BABEL_ENV=coverage nyc mocha 'packages/**/*.test.js' 'docs/**/*.test.js' --exclude '**/node_modules/**' && nyc report -r lcovonly",
"test:coverage:html": "cross-env INTERNAL=true NODE_ENV=test BABEL_ENV=coverage nyc mocha 'packages/**/**/*.test.js' --exclude '**/node_modules/**' && nyc report --reporter=html",
"test:karma": "cross-env INTERNAL=true NODE_ENV=test karma start test/karma.conf.js",
"test:regressions": "yarn test:regressions:build && rimraf test/regressions/screenshots/chrome/* && vrtest run --config test/vrtest.config.js --record",
"test:regressions:build": "webpack --config test/regressions/webpack.config.js",
"test:umd": "node packages/material-ui/test/umd/run.js",
"test:unit": "cross-env NODE_ENV=test mocha 'packages/**/*.test.js' 'docs/**/*.test.js' 'scripts/**/*.test.js' --exclude '**/node_modules/**'",
"test:unit": "cross-env INTERNAL=true NODE_ENV=test mocha 'packages/**/*.test.js' 'docs/**/*.test.js' 'scripts/**/*.test.js' --exclude '**/node_modules/**'",
"test:watch": "yarn test:unit --watch",
"typescript": "lerna run --no-bail --parallel typescript"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/material-ui/src/RootRef/RootRef.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export interface RootRefProps<T = any> {
* );
* }
* ```
*
* @deprecated
* API:
*
* - [RootRef API](https://material-ui.com/api/root-ref/)
Expand Down
17 changes: 17 additions & 0 deletions packages/material-ui/src/RootRef/RootRef.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
import { exactProp, refType } from '@material-ui/utils';
import setRef from '../utils/setRef';

let warnedOnce = false;

/**
* ⚠️⚠️⚠️
* If you want the DOM element of a Material-UI component check out
Expand Down Expand Up @@ -35,6 +37,8 @@ import setRef from '../utils/setRef';
* );
* }
* ```
*
* @deprecated
*/
class RootRef extends React.Component {
componentDidMount() {
Expand All @@ -61,6 +65,19 @@ class RootRef extends React.Component {
}

render() {
if (process.env.NODE_ENV !== 'production') {
if (!warnedOnce && process.env.INTERNAL !== 'true') {
warnedOnce = true;
console.warn(
[
'Material-UI: The RootRef component is deprecated.',
'The component relies on the ReactDOM.findDOMNode API which is deprecated in React.StrictMode.',
'Instead, you can get a reference to the underlying DOM node of the components via the `ref` prop.',
].join('/n'),
);
}
}

return this.props.children;
}
}
Expand Down
1 change: 1 addition & 0 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module.exports = function setKarmaConfig(config) {
'process.env': {
NODE_ENV: JSON.stringify('test'),
CI: JSON.stringify(process.env.CI),
INTERNAL: JSON.stringify(process.env.INTERNAL),
},
}),
],
Expand Down