question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamically change feed group

See original GitHub issue

I’m trying to change the feed group dynamically from a select input inside my Activity component. I’m using the <Feed> component to build the feed context. No matter what I do, I cannot get the feed activities to change when the dynamic feed group is updated:

const Activity = () => {
  const router = useRouter();
  const feedGroup = router.query.id as string;
  return (
    <Feed feedGroup={feedGroup} notify={true}>
      <ActivityFeed />
    </Feed>
  );
};

I’ve tried many things, such as updating the key:

<Feed feedGroup={feedGroup} notify={true} key={feedGroup}>

this results in:

TypeError: Cannot read property 'cancel' of undefined

Which seems to happen when the subscription tries to unregister itself from the useEffect unmount function. Trying to manually unregister didn’t work:

const feedContext = useFeedContext();
useEffect(() => {
  feedContext.feedManager.unsubscribe()
}, [feedContext.feedGroup])

I’ve also tried to refresh after the feed group has changed:

const feedContext = useFeedContext();
useEffect(() => {
  feedContext.refresh()
}, [feedContext.feedGroup])

But this didn’t work either. The only thing I can do is window.location away to another page, refetching the page and infering the feed group from the URL. This isn’t great as the application has to re-initialise itself.

Maybe I’m doing something wrong here?

gz#11830

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
elliosevencommented, May 20, 2021

Beautiful, thanks guys ❤️

0reactions
Rykunocommented, Aug 5, 2021

@ellioseven Is it possible for you to recreate that issue on codesandbox.io? As for the code snippet you shared; everything seems to be okay. I don’t see any issue with the way you’re using the router.

I’m running into the same issue with my routes such as/user/[username].

When navigating away from pages it’s failing cancel on the FeedManager. Quite a bit of work to recreate in a sandbox but i’ll give it a shot after work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create a dynamic feed - Studio Help - Google Support
Open your advertiser and profile. Click Manage Data. Click Edit next to the feed name under "Transformed Content". (Optional) To see the full...
Read more >
Solved: Is it possible to dynamically change which groupin...
Solved: Hi I have created two different groupings (1-2,3-4,5-10) and (1-3,4-7, Other). The groupings are used as legende in a bar chart. Is...
Read more >
How to Dynamically Change Stock Status | CTX Feed - YouTube
In this video, you will learn how to dynamically change stock status with CTX Feed WooCommerce product feed generator plugin.
Read more >
How to dynamically change group on name in RDLC tablix
I want to change the group name dynamically in RDLC report when the rows of same group moves to next page. My mockup...
Read more >
dynamically change priority field on basis of assignment group.
Solved: Hi everyone, I am trying to set default priority as P4 for a particular assignment group. And I am able to achieve(onsubmit...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found