Skip to content
Discussion options

You must be logged in to vote

create a separate resource route for the airtable data so it isn't used in server rendering, then use useFetcher().load(airtableRoute) inside a useEffect hook in your component to load the data after the document hydrates.

// app/routes/index.tsx
export default function Index() {
  let fetcher = useFetcher();
  useEffect(() => {
    fetcher.load('/airtable/getTable');
  }, [])
  return (
    <div>
      {fetcher.data ? <VacanciesList data={fetcher.data.records} /> : null}
    </div>
  )
}

// app/routes/airtable.getTable.ts
export const loader = ({request}) => {
  const baseUrl = new URL(context.request.url);
  return await fetch(`${baseUrl.origin}/api/airtable/getTable`, {
    method: "GET"

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@shamsup
Comment options

@kei4i
Comment options

Answer selected by machour
Comment options

You must be logged in to vote
2 replies
@shamsup
Comment options

@ccssmnn
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants