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

Introduce react-utils package #627

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Introduce react-utils package #627

wants to merge 2 commits into from

Conversation

JoviDeCroock
Copy link
Member

This adds some common utilities for leveraging JSX with signals, I tried to stay in line with how solid provides JSX utils.

Copy link

netlify bot commented Dec 13, 2024

Deploy Preview for preact-signals-demo ready!

Name Link
🔨 Latest commit a278750
🔍 Latest deploy log https://app.netlify.com/sites/preact-signals-demo/deploys/6761d4ffa1acae0008eeb1ae
😎 Deploy Preview https://deploy-preview-627--preact-signals-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

changeset-bot bot commented Dec 13, 2024

🦋 Changeset detected

Latest commit: a278750

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@preact/signals-react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

pnpm-lock.yaml Outdated Show resolved Hide resolved

export function For<T>(props: ForProps<T>): JSX.Element | null {
useSignals();
const cache = useMemo(() => new Map(), []);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need to switch this to a WeakMap when we see the first item being an object or leverage JSON.stringify on objects

Copy link
Contributor

github-actions bot commented Dec 17, 2024

Size Change: 0 B

Total Size: 83.3 kB

ℹ️ View Unchanged
Filename Size
docs/dist/assets/bench.********.js 1.59 kB
docs/dist/assets/client.********.js 46.4 kB
docs/dist/assets/index.********.js 836 B
docs/dist/assets/jsxRuntime.module.********.js 284 B
docs/dist/assets/preact.module.********.js 4.03 kB
docs/dist/assets/signals-core.module.********.js 1.41 kB
docs/dist/assets/signals.module.********.js 2.16 kB
docs/dist/assets/style.********.js 21 B
docs/dist/assets/style.********.css 1.24 kB
docs/dist/basic-********.js 243 B
docs/dist/demos-********.js 3.44 kB
docs/dist/nesting-********.js 1.13 kB
docs/dist/react-********.js 242 B
packages/core/dist/signals-core.js 1.45 kB
packages/core/dist/signals-core.mjs 1.47 kB
packages/preact/dist/signals.js 1.46 kB
packages/preact/dist/signals.mjs 1.43 kB
packages/react-transform/dist/signals-*********.js 4.93 kB
packages/react-transform/dist/signals-transform.mjs 4.16 kB
packages/react-transform/dist/signals-transform.umd.js 5.04 kB
packages/react/dist/signals.js 188 B
packages/react/dist/signals.mjs 150 B

compressed-size-action

Copy link
Member

@rschristian rschristian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might've missed something but is there a particular reason we're offering these specifically and only for React?


interface ShowProps<T = boolean> {
when: Signal<T> | ReadonlySignal<T>;
fallback?: JSX.Element;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to switch to importing JSX, it's (finally!) no longer a global in React 19 AFAIK. It should exist on the React namespace back to 16.

@JoviDeCroock
Copy link
Member Author

@rschristian we will offer it for both but started out with React as the 2.0 release was pending

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.

2 participants