solidjs/solid-start

Use `clientOnly` without isolating component in its own file

Open

#1 929 ouverte le 7 août 2024

Voir sur GitHub
 (4 commentaires) (0 réactions) (0 assignés)HTML (332 forks)batch import
help wanted

Métriques du dépôt

Stars
 (4 187 stars)
Métriques de merge PR
 (Merge moyen 22h 5m) (3 PRs mergées en 30 j)

Description

What is this request related to?

Request

📋 Suggested

https://docs.solidjs.com/solid-start/reference/client/client-only

📋 General description or bullet points

Provide a way of using clientOnly without creating a separate file. Code wise, this could be more ergonomic.

Could also create a helper function to directly translate component function to client only component.

import { clientOnly } from "@solidjs/start"

function ClientOnlyComponent() {
  const location = window.document.location
  return <div>{location.href}</div>
}

type ResolveClientComponent = (value: {
  default: Component
}) => void

export default clientOnly(
  () =>
    new Promise((resolve: ResolveClientComponent) => {
      resolve({ default: ClientOnlyComponent })
    }),
)

🖥️ Reproduction of code samples in StackBlitz

StackBlitz doesn't support solid-start

Guide contributeur