sdy

add useState

1 -import React from "react"; 1 +import React, { useState } from "react";
2 import { useQuery } from "@apollo/react-hooks"; 2 import { useQuery } from "@apollo/react-hooks";
3 import { withRouter } from "react-router-dom"; 3 import { withRouter } from "react-router-dom";
4 import RoomPresenter from "./RoomPresenter"; 4 import RoomPresenter from "./RoomPresenter";
5 import { GET_ROOMS } from "./RoomQueries"; 5 import { GET_ROOMS } from "./RoomQueries";
6 6
7 export default withRouter(() => { 7 export default withRouter(() => {
8 + const [action, setAction] = useState("showList");
9 +
8 const { data } = useQuery(GET_ROOMS); 10 const { data } = useQuery(GET_ROOMS);
9 let roomArray; 11 let roomArray;
10 if (data !== undefined) { 12 if (data !== undefined) {
11 const { getRooms } = data; 13 const { getRooms } = data;
12 roomArray = getRooms; 14 roomArray = getRooms;
13 } 15 }
14 - return <RoomPresenter roomArray={roomArray} />; 16 + return <RoomPresenter roomArray={roomArray} action={action} />;
15 }); 17 });
......