Skip to content
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

Add UNSAFE to near deprecate lifeCycles #6311

Closed
Closed
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion packages/react-router-dom/modules/BrowserRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BrowserRouter extends React.Component {

history = createHistory(this.props);

componentWillMount() {
UNSAFE_componentWillMount() {
warning(
!this.props.history,
"<BrowserRouter> ignores the history prop. To use a custom history, " +
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/HashRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class HashRouter extends React.Component {

history = createHistory(this.props);

componentWillMount() {
UNSAFE_componentWillMount() {
warning(
!this.props.history,
"<HashRouter> ignores the history prop. To use a custom history, " +
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/modules/MemoryRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MemoryRouter extends React.Component {

history = createHistory(this.props);

componentWillMount() {
UNSAFE_componentWillMount() {
warning(
!this.props.history,
"<MemoryRouter> ignores the history prop. To use a custom history, " +
Expand Down
4 changes: 2 additions & 2 deletions packages/react-router/modules/Prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Prompt extends React.Component {
}
}

componentWillMount() {
UNSAFE_componentWillMount() {
invariant(
this.context.router,
"You should not use <Prompt> outside a <Router>"
Expand All @@ -46,7 +46,7 @@ class Prompt extends React.Component {
if (this.props.when) this.enable(this.props.message);
}

componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
if (nextProps.when) {
if (!this.props.when || this.props.message !== nextProps.message)
this.enable(nextProps.message);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/modules/Redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Redirect extends React.Component {
return this.context.router && this.context.router.staticContext;
}

componentWillMount() {
UNSAFE_componentWillMount() {
invariant(
this.context.router,
"You should not use <Redirect> outside a <Router>"
Expand Down
4 changes: 2 additions & 2 deletions packages/react-router/modules/Route.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Route extends React.Component {
return matchPath(pathname, { path, strict, exact, sensitive }, route.match);
}

componentWillMount() {
UNSAFE_componentWillMount() {
warning(
!(this.props.component && this.props.render),
"You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored"
Expand All @@ -92,7 +92,7 @@ class Route extends React.Component {
);
}

componentWillReceiveProps(nextProps, nextContext) {
UNSAFE_componentWillReceiveProps(nextProps, nextContext) {
warning(
!(nextProps.location && !this.props.location),
'<Route> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.'
Expand Down
4 changes: 2 additions & 2 deletions packages/react-router/modules/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Router extends React.Component {
};
}

componentWillMount() {
UNSAFE_componentWillMount() {
const { children, history } = this.props;

invariant(
Expand All @@ -64,7 +64,7 @@ class Router extends React.Component {
});
}

componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
warning(
this.props.history === nextProps.history,
"You cannot change <Router history>"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/modules/StaticRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class StaticRouter extends React.Component {

handleBlock = () => noop;

componentWillMount() {
UNSAFE_componentWillMount() {
warning(
!this.props.history,
"<StaticRouter> ignores the history prop. To use a custom history, " +
Expand Down
4 changes: 2 additions & 2 deletions packages/react-router/modules/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class Switch extends React.Component {
location: PropTypes.object
};

componentWillMount() {
UNSAFE_componentWillMount() {
invariant(
this.context.router,
"You should not use <Switch> outside a <Router>"
);
}

componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
warning(
!(nextProps.location && !this.props.location),
'<Switch> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("A <Switch>", () => {
let mountCount = 0;

class App extends React.Component {
componentWillMount() {
UNSAFE_componentWillMount() {
mountCount++;
}

Expand Down