Skip to content

Move module-scope Emitter in react.tsx into the Provider #391

@Zaimwa9

Description

@Zaimwa9

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions