Skip to content

Commit

Permalink
SSR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SemaiCZE committed Nov 3, 2017
1 parent cd22f9b commit 8920f8c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
13 changes: 7 additions & 6 deletions src/containers/GroupsNameContainer/GroupsNameContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ import GroupsName, {

class GroupsNameContainer extends Component {
componentWillMount() {
GroupsNameContainer.loadData(this.props);
this.props.loadAsync();
}

componentWillReceiveProps(newProps) {
if (this.props.groupId !== newProps.groupId) {
GroupsNameContainer.loadData(newProps);
newProps.loadAsync();
}
}

static loadData = ({ loadGroupIfNeeded }) => {
loadGroupIfNeeded();
static loadAsync = ({ groupId }, dispatch) => {
dispatch(fetchPublicGroupIfNeeded(groupId));
};

render() {
Expand All @@ -38,14 +38,15 @@ class GroupsNameContainer extends Component {
GroupsNameContainer.propTypes = {
groupId: PropTypes.string.isRequired,
group: ImmutablePropTypes.map,
noLink: PropTypes.bool
noLink: PropTypes.bool,
loadAsync: PropTypes.func.isRequired
};

export default connect(
(state, { groupId }) => ({
group: publicGroupSelector(groupId)(state)
}),
(dispatch, { groupId }) => ({
loadGroupIfNeeded: () => dispatch(fetchPublicGroupIfNeeded(groupId))
loadAsync: () => GroupsNameContainer.loadAsync({ groupId }, dispatch)
})
)(GroupsNameContainer);
10 changes: 5 additions & 5 deletions src/containers/UsersNameContainer/UsersNameContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ import UsersName, {

class UsersNameContainer extends Component {
componentWillMount() {
this.props.loadData();
this.props.loadAsync();
}

componentWillReceiveProps(newProps) {
if (this.props.userId !== newProps.userId) {
newProps.loadData();
newProps.loadAsync();
}
}

static loadData = (userId, dispatch) => {
static loadAsync = ({ userId }, dispatch) => {
dispatch(fetchProfileIfNeeded(userId));
};

Expand Down Expand Up @@ -55,7 +55,7 @@ UsersNameContainer.propTypes = {
large: PropTypes.bool,
user: ImmutablePropTypes.map,
noLink: PropTypes.bool,
loadData: PropTypes.func.isRequired
loadAsync: PropTypes.func.isRequired
};

export default connect(
Expand All @@ -65,6 +65,6 @@ export default connect(
}),
(dispatch, { userId }) => ({
loadProfileIfNeeded: () => dispatch(fetchProfileIfNeeded(userId)),
loadData: () => UsersNameContainer.loadData(userId, dispatch)
loadAsync: () => UsersNameContainer.loadAsync({ userId }, dispatch)
})
)(UsersNameContainer);
4 changes: 2 additions & 2 deletions src/pages/Exercise/Exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const messages = defineMessages({
class Exercise extends Component {
state = { forkId: null };

static loadAsync = (dispatch, exerciseId) =>
static loadAsync = ({ exerciseId }, dispatch) =>
Promise.all([
dispatch(fetchExerciseIfNeeded(exerciseId)),
dispatch(fetchReferenceSolutionsIfNeeded(exerciseId)),
Expand Down Expand Up @@ -467,7 +467,7 @@ export default withLinks(
};
},
(dispatch, { params: { exerciseId } }) => ({
loadAsync: () => Exercise.loadAsync(dispatch, exerciseId),
loadAsync: () => Exercise.loadAsync({ exerciseId }, dispatch),
assignExercise: groupId =>
dispatch(assignExercise(groupId, exerciseId)),
push: url => dispatch(push(url)),
Expand Down

0 comments on commit 8920f8c

Please sign in to comment.