Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

The children utility function causes the child components to initialize in advance. #279

@siaikin

Description

@siaikin

Describe the bug

I use Context to inject some data globally, and I optimize the access to children according to the examples given in the tutorial, that is, using the children utility function to wrap props.children. However, the child components always access the initialValue of createContext through useContext, instead of the data I provide through Provider.

Your Example Website or App

https://playground.solidjs.com/anonymous/29fa1b7c-efd7-4f32-a6f7-1a37c22b047c

Steps to Reproduce the Bug or Issue

  1. Go to https://playground.solidjs.com/anonymous/29fa1b7c-efd7-4f32-a6f7-1a37c22b047c
  2. Button render -1, this is initialValue.
  3. Please comment out this IS NOT WORK code, 16-19 lines.
  4. Than comment in IS WORK code, 22-24 lines.
  5. Butten Render -2, this is provide by Context.Provider.

Expected behavior

I hope that when using the children utility function, the child components will not be initialized in advance, causing useContext to be unable to get the provided value.

Screenshots or Videos

No response

Platform

  • OS: Windows
  • Browser: Chrome

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions