patch React compilation warnings and useEffect dependencies

This commit is contained in:
sorrelbri 2020-02-07 16:11:01 -08:00
parent 4c7fa1512d
commit 2c5a0534d7
5 changed files with 8 additions and 12 deletions

View file

@ -1,4 +1,4 @@
import React, { useEffect, useReducer} from 'react'; import React, { useEffect, useReducer } from 'react';
import { Switch, Route, BrowserRouter as Router } from 'react-router-dom'; import { Switch, Route, BrowserRouter as Router } from 'react-router-dom';
import MainWrapper from './pages/Layout/MainWrapper/MainWrapper'; import MainWrapper from './pages/Layout/MainWrapper/MainWrapper';
import { stateReducer } from './reducers/reducer'; import { stateReducer } from './reducers/reducer';
@ -13,7 +13,6 @@ function App() {
{}, {},
initState initState
); );
useEffect(() => { useEffect(() => {
const fetchIndexAPI = async () => { const fetchIndexAPI = async () => {
@ -28,7 +27,7 @@ function App() {
} }
} }
fetchIndexAPI(); fetchIndexAPI();
}, []) }, [ ])
useEffect(() => { useEffect(() => {

View file

@ -24,7 +24,7 @@ const Game = (props) => {
} }
} }
fetchGameAPI(); fetchGameAPI();
}, [ gameId ]) }, [ gameId, dispatch ])
useEffect(() => { useEffect(() => {
@ -39,7 +39,7 @@ const Game = (props) => {
return dispatch(action); return dispatch(action);
} }
roomSocketConnect(); roomSocketConnect();
}, [ state.active ] ) }, [ state.active , dispatch, state.user ] )
return ( return (
<div <div

View file

@ -37,7 +37,7 @@ const Home = props => {
} }
} }
fetchRoomsAPI(); fetchRoomsAPI();
}, []) }, [ dispatch ])
return ( return (
<div className="Home" data-testid="Home"> <div className="Home" data-testid="Home">

View file

@ -1,8 +1,6 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect } from 'react';
import { useParams } from 'react-router-dom'; import { useParams } from 'react-router-dom';
import './Room.scss'; import './Room.scss';
import socketIOClient from 'socket.io-client';
import config from '../../config';
import roomsServices from '../../services/api/roomsServices'; import roomsServices from '../../services/api/roomsServices';
import GameButton from '../../components/Button/Game/Game'; import GameButton from '../../components/Button/Game/Game';
import Message from '../../components/Display/Message/Message'; import Message from '../../components/Display/Message/Message';
@ -29,7 +27,7 @@ const Room = (props) => {
} }
} }
fetchRoomAPI(); fetchRoomAPI();
}, [ roomId ]) }, [ roomId, dispatch ])
useEffect(() => { useEffect(() => {
const roomSocketConnect = () => { const roomSocketConnect = () => {
@ -41,7 +39,7 @@ const Room = (props) => {
dispatch(action) dispatch(action)
} }
roomSocketConnect(); roomSocketConnect();
}, [ roomId, state.user ]) }, [ roomId, state.user, dispatch ])
const renderGames = () => { const renderGames = () => {
const games = state.games || []; const games = state.games || [];

View file

@ -1,7 +1,6 @@
//@ flow //@ flow
import type { state } from '../reducer'; import type { state } from '../reducer';
const socket = require('../../io');
export const initState = (): state => { export const initState = (): state => {
return { return {