Skip to content

Instantly share code, notes, and snippets.

@heytulsiprasad
Created September 23, 2021 08:49
Show Gist options
  • Save heytulsiprasad/13afc1e2a8952a68e30a4288d46c7d59 to your computer and use it in GitHub Desktop.
Save heytulsiprasad/13afc1e2a8952a68e30a4288d46c7d59 to your computer and use it in GitHub Desktop.
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);
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