Skip to content

ScopeProvider is not updating the value? #71

Description

Not sure if it is a bug in bunshi or just it is how it is :)

Bug

ScopeProvider seems to not updating its value before nested component with a molecule tries to read it, f.e.

<ScopeProvider scope={SomeScope} value={condition ? 'meaningfullValue' : null}>
   {condition ? <UsesScopeMolecule /> : <NoScopes />
</ScopeProvider>

when the condition changes to true, <UsesScopeMolecule /> that requires the 'meaningfullValue' will receive null on first mount. Adding key that forces react to re-create the ScopeProvider on each value change seems to fix the problem.

Reproduction

https://stackblitz.com/edit/vitejs-vite-aouwed?file=src%2FApp.tsx

Bunshi version

Tested on 2.1.4 and 2.1.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions