SolidJSS
SolidJSโ€ข3y agoโ€ข
3 replies
anhvu0911

Questions on the `owner` of using children() helper inside a context

I'm writing a component to show Toast.

The idea is to wrap the main component inside a ToastContext. It exposes a method success() to show a Toast for a successful action.
The shorten demo code is here https://playground.solidjs.com/anonymous/b8a41bdc-5569-41a0-86f5-d8fe42583d8f

- If I used props.children inside the ToastContext, then the component can useContext normally. We can see the context in the owner chain
- If I used children() helper inside the ToastContext, when the component use useContext , it results in a undefined context. There is no context in the owner chain

So:
- Why using children() helper does not keep the correct owner?
- How is an owner attached? I assume that as long as it is inside a JSX element, that JSX element is the owner, but it seems not to be the case here.
Quickly discover what the solid compiler will generate from your JSX template
Was this page helpful?