Skip to content

Commit

Permalink
use useCallback when needed, from components
Browse files Browse the repository at this point in the history
  • Loading branch information
daltonfury42 committed Feb 14, 2021
1 parent 65e2c1b commit bb8f29a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
5 changes: 3 additions & 2 deletions simplq/src/components/pages/Status/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import HeaderSection from 'components/common/HeaderSection';
import React, { useEffect } from 'react';
import React, { useEffect, useCallback } from 'react';

import { useDispatch, useSelector } from 'react-redux';
import { useGetToken } from 'store/asyncActions';
import { selectToken } from 'store/token';
Expand All @@ -13,7 +14,7 @@ function QueueStatus(props) {
const tokenId = props.match.params.tokenId;
const dispatch = useDispatch();
const token = useSelector(selectToken);
const getToken = useGetToken();
const getToken = useCallback(useGetToken(), []);

useEffect(() => {
dispatch(getToken({ tokenId, refresh: true }));
Expand Down
3 changes: 1 addition & 2 deletions simplq/src/store/asyncActions/deleteToken.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createAsyncThunk } from '@reduxjs/toolkit';
import { useMakeAuthedRequest } from 'api/auth';
import * as RequestFactory from 'api/requestFactory';
import { useCallback } from 'react';
import { useDispatch } from 'react-redux';
import { useHistory } from 'react-router';
import { setInfoPopupMessage } from 'store/appSlice';
Expand Down Expand Up @@ -29,7 +28,7 @@ const useDeleteToken = () => {
return response;
});

return useCallback(deleteToken, []);
return deleteToken;
};

const deleteToken = createAsyncThunk(typePrefix);
Expand Down
3 changes: 1 addition & 2 deletions simplq/src/store/asyncActions/getToken.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createAsyncThunk } from '@reduxjs/toolkit';
import useAuth, { makeAuthedRequest } from 'api/auth';
import * as RequestFactory from 'api/requestFactory';
import { useCallback } from 'react';

const typePrefix = 'getToken/action';
let timer = null;
Expand Down Expand Up @@ -29,7 +28,7 @@ const useGetToken = () => {
return response;
});

return useCallback(getToken, []);
return getToken;
};

const getToken = createAsyncThunk(typePrefix);
Expand Down

0 comments on commit bb8f29a

Please sign in to comment.