RoomContainer.js 582 Bytes
import React, { useState } from "react";
import { useQuery } from "@apollo/react-hooks";
import { withRouter } from "react-router-dom";
import RoomPresenter from "./RoomPresenter";
import { GET_ROOMS } from "./RoomQueries";

export default withRouter(() => {
  const [action, setAction] = useState("showList");

  const { data } = useQuery(GET_ROOMS);
  let roomArray;
  if (data !== undefined) {
    const { getRooms } = data;
    roomArray = getRooms;
  }
  return (
    <RoomPresenter
      roomArray={roomArray}
      action={action}
      setAction={setAction}
    />
  );
});