Move module-scope Emitter in react.tsx into the Provider
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 58/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- react, typescript
- Domain
- frontend
Research direction
Start in react.tsx, locating the module-scope Emitter, FlagsmithProvider, its context, and the hooks that consume the event bus. Move emitter ownership into each provider and expose it through context alongside flagsmith. Done means separate provider trees no longer share notifications, including on long-lived Node or SSR hosts.
Written by the indexing model from the issue text.
Description
react.tsx instantiates a single Emitter at module scope, which means all <FlagsmithProvider> trees in a process share the same event bus.
On long-lived Node hosts (Fluid Compute, serverful SSR) this is a cross-request coupling hazard setups it causes unrelated providers to notify each other's hooks (safe today thanks to value comparisons).
Objective
Move the emitter to a useRef in FlagsmithProvider and pass it via context alongside flagsmith; hooks read it from context.
Surfaced by #390
- Dominant language
- TypeScript
- Stars
- 67
- Forks
- 47
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Flagsmith/flagsmith-js-client
-
`init({ traits })` double-wraps `{ value, transient }` trait objects, sending a nested `trait_value`Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Flagsmith/flagsmith-js-client#444 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Flagsmith/flagsmith-js-client#445 ·
-
Dependency DashboardOpen
Difficulty 1/5 Under an hour Newbie friendliness 20/100
Flagsmith/flagsmith-js-client#435 ·
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
Flagsmith/flagsmith-js-client#371 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Flagsmith/flagsmith-js-client#330 ·
All issues in Flagsmith/flagsmith-js-client
Similar issues
-
ui
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
mermaid-js/mermaid-v13#1370 ·
Maintainers usually reply within 1 day
-
compiler: the island_chunks_not_emitted report gives a count but not which islands were skippedOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Broken Website
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
darkreader/darkreader#16259 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ARTPARK-SAHAI-ORG/calibrate-frontend#919 ·
Maintainers usually reply within 1 day