Skip to content

Commit 73124cb

Browse files
committed
context? WE DON’T NEED NO [BLANKING] CONTEXT 😡
1 parent 07ca990 commit 73124cb

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

website/examples/Auth.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,26 @@ const Public = () => <h3>Public</h3>
7878

7979
////////////////////////////////////////////////////////////
8080
class Login extends React.Component {
81-
static contextTypes = {
82-
location: PropTypes.object,
83-
router: PropTypes.object
81+
82+
state = {
83+
redirectToReferrer: false
8484
}
8585

8686
login = () => {
87-
const { location } = this.props
88-
8987
fakeAuth.authenticate(() => {
90-
this.context.router.replaceWith(location.state.from)
88+
this.setState({ redirectToReferrer: true })
9189
})
9290
}
9391

9492
render() {
9593
const { from } = this.props.location.state
94+
const { redirectToReferrer } = this.state
9695

9796
return (
9897
<div>
98+
{redirectToReferrer && (
99+
<Redirect to={from || '/'}/>
100+
)}
99101
{from && (
100102
<p>
101103
You must log in to view the page at

0 commit comments

Comments
 (0)