Created
September 23, 2021 08:49
-
-
Save heytulsiprasad/13afc1e2a8952a68e30a4288d46c7d59 to your computer and use it in GitHub Desktop.
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
import React from "react"; | |
import { connect } from "react-redux"; | |
import { loadMoreChatrooms } from "actions"; | |
import AllChatrooms from "./AllChatrooms"; | |
const Profile = ({ chatrooms, loadMoreChatrooms }) => { | |
return ( | |
<div> | |
<AllChatrooms chatrooms={chatrooms} /> | |
<button onClick={loadMoreChatrooms}>Load more</button> | |
</div> | |
); | |
}; | |
const mapStateToProps = state => ({ | |
chatrooms: state.allChatrooms | |
}); | |
const mapDispatchToProps = { loadMoreChatrooms }; | |
export default connect(mapStateToProps, mapDispatchToProps)(Profile); |
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
import React from "react"; | |
import { useSelector, useDispatch } from "react-redux"; | |
import { loadMoreChatrooms } from "actions"; | |
import AllChatrooms from "./AllChatrooms"; | |
const Profile = () => { | |
const chatrooms = useSelector(state => state.allChatrooms); | |
const dispatch = useDispatch() | |
return ( | |
<div> | |
<AllChatrooms chatrooms={chatrooms} /> | |
<button onClick={() => dispatch(loadMoreChatrooms())}>Load more</button> | |
</div> | |
); | |
}; | |
export default Profile; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment