gglukmann / use-google-sheets

📝 A React Hook for getting data from Google Sheets API v4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is the data memoized?

fotoflo opened this issue · comments

Im rewriting my display of the data now (a table) - react-table wants a memoized data set. Is the data memoized? I'm sorry I'm kind of a noob. If not memoized how do i memoize it?

const {
    data: sheetData,
    loading,
    error,
  } = useMemo(() => {
    return useGoogleSheets({
      apiKey: GAPI_CONFIG.apiKey,
      sheetId,
    });
  }, [sheetId]);

React Hook "useGoogleSheets" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.

You can get the data from google sheets and then memoize it.

const { data } = useGoogleSheets({ apiKey, sheetId });
const sheetData = React.useMemo(() => data, [data, sheetId]);