Skip to content

Providing context to generated components in Solid doesn't work #49

@jsimonrichard

Description

@jsimonrichard

Initial checklist

Affected package

rehype-react@8.0.0

Steps to reproduce

Minimal reproducible example: https://codesandbox.io/p/devbox/mjnc4d
(no extra steps are required).

Actual behavior

It looks like a new reactive environment/context (whatever it's called) for Solid is being created based on this warning in browser's console: computations created outside a 'createRoot' or 'render' will never be disposed and the fact that context (using createContext) isn't passed down to components inserted through the components option of rehypeReact.

This is in contrast with rehype-react + React, with which it's possible to access context inside these inserted components.

Expected behavior

I expect the value of MyContext, set by MyContext.Provider, to be accessible inside interactive components inserted by rehype-react.

This is needed (I believe) for my use-case since I'm trying to render books (in asciidoc) with stateful, interactive content, and the content state needs to be saved on a per-user basis. Therefore I'm trying to use Context to pass user-specific data to the interactive components.

Runtime

node@20.12.0; Chrome (Brave): 1.73.89 Chromium: 131.0.6778.69 (Official Build) (64-bit)

Package manager

npm@10.5.0

Operating system

Arch Linux (kernel: 6.6.67-1-lts)

Build and bundle tools

Vite

Metadata

Metadata

Assignees

No one assigned

    Labels

    🤞 phase/openPost is being triaged manually

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions