All files / hooks useStartEvolve.tsx

69.23% Statements 9/13
100% Branches 0/0
50% Functions 2/4
72.72% Lines 8/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 191x 1x     1x 170x 85x   85x           85x     1x  
import {gameEvolve, gameToggleEvolve} from '../redux/gameSlice';
import {useDispatch, useSelector} from 'react-redux';
import {RootState} from '../redux/store';
 
const useStartEvolve = (ref: any) => {
    const {timeSpeed} = useSelector((state: RootState) => state.gameSlice);
    const dispatch = useDispatch();
 
    const fn = () => {
        dispatch(gameToggleEvolve(true));
        dispatch(gameEvolve());
        ref.current = setTimeout(() => fn(), timeSpeed);
    };
 
    return fn;
};
 
export default useStartEvolve;