Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

297
Views
React-table doesn't update when MobX store updates

I am using react-table, which depends on some MobX observable data. My component is wrapped with observer() and my table row data is memoized using useMemo, as you do with react-table. The problem is, this useMemo doesn't react to store updates.

  const fetcher = useDataFetcher(props.selected, bookmarkStore.f.loadBare);

  // this loads additional row data using a mobx store action
  useEffect(() => {
    (async () => {
      const ids = fetcher.items.results.map((a) => a.document);
      await documentStore.loadIds(ids);
    })();
  }, [fetcher.items.results]);

  // this doesn't get updated when new ids are loaded, affecting documentStore.docsById
  const bookmarks = useMemo(
    () =>
      fetcher.items.results.map((bookmark) => {
        let docId = bookmark.document;
        const doc = documentStore.getDocById(docId);
        return { ...bookmark, document_data: doc };
      }),
    [fetcher.items.results,
     documentStore.docsById // this is the dependency that doesn't do anything
    ]
  );

  const data = bookmarks;

  // setup react-table with this data

And I can't remove the useMemo call because then the react-table goes into infinite re-render, crashing the app. Can I somehow get rid of useMemo when using react-table or is there a way for this useMemo store dependency to work?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!