Advertisement
yuvarajupadhyaya

Get redux data in component

Nov 24th, 2022
721
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.87 KB | Source Code | 0 0
  1. import { Input } from "@mui/material";
  2. import React from "react";
  3. import { Search } from "react-feather";
  4. import { connect } from "react-redux";
  5. import { GetDashboardContent } from "@clientApp/actions/dashboardAction";
  6. import axios from "axios";
  7. import { BaseApiUrl } from "../../../constants/apiRoutes";
  8.  
  9. function JoinClassroom(props) {
  10.   const { UserDetailSection } = props.dashboardReducer;
  11.  
  12.   React.useEffect(() => {
  13.     if (!UserDetailSection || UserDetailSection.length == 0) {
  14.       props.GetDashboardContent();
  15.     }
  16.   }, []);
  17.  
  18.   React.useEffect(() => {
  19.     //Fetch classroomlist
  20.     axios
  21.       .get(
  22.         BaseApiUrl +
  23.           `ClassRoom/GetClassRoomListNewJoin`
  24.       )
  25.       .then((response) => {
  26.         console.log("response of GetClassRoomListNewJoin:", response);
  27.         //setClassrooms(response.data.Result);
  28.       })
  29.       .catch((error) => console.log(error));
  30.   }, [props.dashboardReducer]);
  31.  
  32.   return (
  33.     <div>
  34.       <div className="page-head">
  35.         <h2 className="page-title  mt30  mb10">Join New Classroom</h2>
  36.         <div className="margin-left-auto">
  37.           <div className="form-group form-search">
  38.             <Input
  39.               name="SearchTerm"
  40.               className="custom-search-box"
  41.               placeholder="Search..."
  42.               type="text"
  43.               // value={SearchTerm}
  44.               // onChange={this.handleChange}
  45.               // onKeyDown={this.handleKeyPress}
  46.             />
  47.             <Search
  48.               className="search-icon"
  49.               size={16}
  50.               // onClick={() => this.handleSearch()}
  51.             />
  52.           </div>
  53.         </div>
  54.       </div>
  55.     </div>
  56.   );
  57. }
  58.  
  59. const mapStateToProps = (state) => {
  60.   const { dashboardReducer } = state;
  61.   return { dashboardReducer };
  62. };
  63. export default connect(mapStateToProps, { GetDashboardContent })(JoinClassroom);
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement