Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ClientOnly component #38

Merged
merged 1 commit into from
Nov 27, 2023
Merged

Conversation

magne4000
Copy link
Member

Same as vikejs/vike-react#35 but for Solid.

Closes #36

Usage

import { createSignal } from "solid-js";
import { ClientOnly } from "vike-solid/ClientOnly";

export { Counter };

function Counter() {
  const [count, setCount] = createSignal(0);

  return (
    <>
      <button onClick={() => setCount((count) => count + 1)}>
        Counter {count()}
      </button>
      <ClientOnly load={() => import('../star-wars/index/+Page')}>
        {(Page) => <Page movies={[{ id: '1', title: `${count()}`, release_date: 'today' }]} />}
      </ClientOnly>
    </>
  );
}

@magne4000 magne4000 merged commit 9c99fec into main Nov 27, 2023
6 checks passed
@magne4000 magne4000 deleted the magne4000/client-only-component branch November 27, 2023 10:07
@brillout
Copy link
Member

Very neat 🚀

I wonder, do we need deps in Solid?

Other than deps, the interface is exactly the same, correct? Context: vikejs/vike#1289.

@brillout
Copy link
Member

FYI @usk94

@magne4000
Copy link
Member Author

I wonder, do we need deps in Solid?

We do not, thanks to how Solid works internally 🚀.

@magne4000
Copy link
Member Author

Other than deps, the interface is exactly the same, correct? Context: vikejs/vike#1289.

And yes, almost a copy paste, so no difference beside not needing deps.

@brillout
Copy link
Member

Nice 👌 FYI I made a little commit: 031c1fe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<ClientOnly> Component
2 participants