How to embed react in solidjs. #2445
-
I want to use platejs and can't find anything remotely comparable in the solidjs/vanilla ecosystem. Educate me. Until then, I thought I could embed a react component easily in my solidjs project. I'm wrong. Here's my approach that fails. Has anyone done this already? @ryansolid ??? import {Component, onMount} from "solid-js"
import {createRoot} from "react-dom/client"
import React, {createElement, ReactNode} from "react"
function Profile() {
return (
<img src="https://i.imgur.com/MK3eW3As.jpg" alt="Katherine Johnson" />
)
}
export default function (props) {
let reactRoot: HTMLDivElement | null = null
onMount(() => {
const root = createRoot(reactRoot)
root.render(createElement(<Profile/>, null))
})
return (
<div>
<h1>SolidJS Component</h1>
<div ref={reactRoot}></div>
</div>
)
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
I have to admit I haven't worked much on this direction recently. Originally I made this demo: https://codesandbox.io/p/sandbox/solid-react-hoc-8m2yd?file=%2Fsolid-react.jsx. But more of the focus and work has been the other way of putting Solid in existing React apps: https://stackblitz.com/edit/hr-meheraj-vite-react-rr54iq?file=src%2FApp.jsx This is mostly because while people have no choice to deal with existing React projects and we need to make it easier to use Solid, the other direction generally isn't as beneficial. If you are already using Solid, using React will generally be a negative. We have most ecosystem libraries we need. |
Beta Was this translation helpful? Give feedback.
-
The React ecosystem is the #1 reason people are slow to convert to Solidjs
in my experience.
If we can make it easy to consume large open source react components, I
believe it would remove that barrier
…On Thu, Mar 13, 2025 at 7:56 PM Ryan Carniato ***@***.***> wrote:
I have to admit I haven't worked much on this direction recently.
Originally I made this demo:
https://codesandbox.io/p/sandbox/solid-react-hoc-8m2yd?file=%2Fsolid-react.jsx
.
But more of the focus and work has been the other way of putting Solid in
existing React apps:
https://stackblitz.com/edit/hr-meheraj-vite-react-rr54iq?file=src%2FApp.jsx
This is mostly because while people have no choice to deal with existing
React projects and we need to make it easier to use Solid, the other
direction generally isn't as beneficial. If you are already using Solid,
using React will generally be a negative. We have most ecosystem libraries
we need.
—
Reply to this email directly, view it on GitHub
<#2445 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACM3OSKVYPKAPSA5A2X5EL2UGTBLAVCNFSM6AAAAABY5WA7Z2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENBZGA2TANI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
... and btw, I have since found this vanilla project that seems very promising and does not require react |
Beta Was this translation helpful? Give feedback.
I have to admit I haven't worked much on this direction recently. Originally I made this demo: https://codesandbox.io/p/sandbox/solid-react-hoc-8m2yd?file=%2Fsolid-react.jsx.
But more of the focus and work has been the other way of putting Solid in existing React apps: https://stackblitz.com/edit/hr-meheraj-vite-react-rr54iq?file=src%2FApp.jsx
This is mostly because while people have no choice to deal with existing React projects and we need to make it easier to use Solid, the other direction generally isn't as beneficial. If you are already using Solid, using React will generally be a negative. We have most ecosystem libraries we need.