patch React compilation warnings and useEffect dependencies
This commit is contained in:
parent
4c7fa1512d
commit
2c5a0534d7
5 changed files with 8 additions and 12 deletions
|
@ -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';
|
||||||
|
@ -14,7 +14,6 @@ function App() {
|
||||||
initState
|
initState
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchIndexAPI = async () => {
|
const fetchIndexAPI = async () => {
|
||||||
const response = await indexServices.indexService();
|
const response = await indexServices.indexService();
|
||||||
|
@ -28,7 +27,7 @@ function App() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fetchIndexAPI();
|
fetchIndexAPI();
|
||||||
}, [])
|
}, [ ])
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -37,7 +37,7 @@ const Home = props => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fetchRoomsAPI();
|
fetchRoomsAPI();
|
||||||
}, [])
|
}, [ dispatch ])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="Home" data-testid="Home">
|
<div className="Home" data-testid="Home">
|
||||||
|
|
|
@ -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 || [];
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue