Skip to content

Commit 6783b9b

Browse files
committed
- refactor various components to be able to use context API
1 parent 45340d6 commit 6783b9b

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

imports/ui/components/forgot_password.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class ForgotPassword extends React.Component {
3939

4040
render() {
4141
const { validated, error, success, processing } = this.state;
42-
const { isLoggedIn } = this.context
42+
const { user } = this.context
4343

4444
return (
45-
isLoggedIn ? <Redirect to='/home' /> :
45+
user ? <Redirect to='/home' /> :
4646
<Container fluid>
4747
<Row>
4848
<Col sm={{ span: 6, offset: 3 }} lg={{ span: 4, offset: 4 }}>
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import React from 'react';
22
import { Container, Row, Col } from 'react-bootstrap';
3+
import { AuthContext } from './hoc/AuthProvider'
34
import BoardContainer from '/imports/ui/containers/board.jsx';
45

5-
const Moderator = props => {
6-
const { user } = props;
7-
const { name } = user && user.profile || {}
8-
return (
9-
<Container>
6+
class Moderator extends React.Component {
7+
constructor(props) {
8+
super(props)
9+
}
10+
11+
render() {
12+
const { user } = this.context
13+
const { name } = user && user.profile || {}
14+
15+
return (
16+
<Container>
1017
<Row>
1118
<Col className="h-100" style={{marginTop:40}}>
1219
<hgroup className="mx-auto p-4 text-center">
@@ -16,8 +23,9 @@ const Moderator = props => {
1623
</Col>
1724
</Row>
1825
</Container>
19-
20-
)
26+
)
27+
}
2128
}
2229

30+
Moderator.contextType = AuthContext
2331
export default Moderator

0 commit comments

Comments
 (0)