Fixed RemyAssistant.tsx - Where useeffect causes destroy is not a function error#446
Fixed RemyAssistant.tsx - Where useeffect causes destroy is not a function error#446killerfrienddk wants to merge 4 commits into
Conversation
… a function error
📝 WalkthroughWalkthroughThe effect synchronizing ChangesRemyAssistant subscription handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@packages/create/src/frameworks/react/examples/events/assets/src/components/RemyAssistant.tsx`:
- Around line 91-94: The component currently calls
showRemyAssistant.subscribe(...) in the component body causing listener leaks
and render storms; move the subscription into a useEffect that runs on mount,
capture the returned Subscription and call subscription.unsubscribe() in the
effect cleanup, and keep setIsOpen inside the subscription callback;
alternatively (preferred) import and use the `@tanstack/react-store` useStore hook
to subscribe automatically and remove the duplicated local state and manual
subscribe/unsubscribe logic (references: showRemyAssistant, setIsOpen,
subscribe, unsubscribe, useEffect, useStore).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: de3939c1-82ac-4a01-87fa-e785d35e0ced
📒 Files selected for processing (1)
packages/create/src/frameworks/react/examples/events/assets/src/components/RemyAssistant.tsx
…use effect I have now studied up more regarding useeffect and understand why coderabbit said what it said
Reproduction:
I changed:
useEffect(() => { return showRemyAssistant.subscribe(() => { setIsOpen(showRemyAssistant.state) }) }, [])to:
useEffect(() => { const subscription = showRemyAssistant.subscribe(() => { setIsOpen(showRemyAssistant.state) }) return () => subscription.unsubscribe() }, [])Summary by CodeRabbit