This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Container extends React.Component { | |
constructor(props) { | |
super(props); | |
} | |
componentDidMount() { | |
if(!this.props.friendsFetched) { | |
FriendsService.fetchFriends().then((data) => { | |
this.props.onFriendsFetch(data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const INITIAL_STATE = { | |
friends: [], | |
friendsFetched: false | |
}; | |
function(state = INITIAL_STATE, action) { | |
switch(action.type) { | |
case 'FRIENDS_FETCHED': | |
return { | |
...state, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const onFriendsFetch = (friendsData) => { | |
return { | |
type: 'FRIENDS_FETCHED', | |
payload: friendsData | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Container extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
friends: [] | |
}; | |
} | |
componentDidMount() { |