Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the data memoized? #32

Open
fotoflo opened this issue Jul 27, 2022 · 1 comment
Open

Is the data memoized? #32

fotoflo opened this issue Jul 27, 2022 · 1 comment

Comments

@fotoflo
Copy link

fotoflo commented Jul 27, 2022

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.

@gglukmann
Copy link
Owner

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants