Repository navigation
Conversation
commit: |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v5 #5657 +/- ##
=====================================
Coverage ? 80.24%
=====================================
Files ? 132
Lines ? 10578
Branches ? 2300
=====================================
Hits ? 8488
Misses ? 2090
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Hey @kotarotaniguchi0523 @ashunar0! Can you review this if you have time? |
|
@yusukebe sure! I'll check this tomorrow! |
|
@yusukebe Me too! I'll check this tomorrow. |
|
I reviewed this. I think the direction of Signals is good. Here are some things I found while running it. 1.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Hey @ashunar0 ! Thank you for the review. These make sense to me. I fixed them with AI, but I understood what they did. Can you review this again?
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Thanks for the fixes! I checked them all, and they work. I also ran a fuzz test on the new One small thing: an async component that returns a signal renders const s = signal('async')
const C = async () => s
await (<div><C /></div>).toString() // <div>[object Object]</div>It's not in the types either, so I think it's fine to leave it unsupported. LGTM! |
|
Sorry for the delay! I think the overall direction looks good, but I have a couple of suggestions. Proposal 1: Separate component setup from renderingThe JSDoc (L365–366) clearly states that However, if we accidentally change the call order by using a conditional branch, perComponent() (L47–49) may reuse the wrong signal without throwing an error. Even though this restriction is documented, such mistakes can be difficult to notice. Could we remove this restriction itself? My suggestion is to change the component execution logic in the DOM renderer to allow components to return a render function.
With this approach, we could use conditional branches and loops during setup. We would also no longer need to manage state based on call order, including Proposal 2: Reactive access to propsThe current implementation uses callbacks from the latest render through the following code: However, as described in the JSDoc for computed(), changes to regular props alone do not trigger reevaluation. If we separate setup from rendering, could we use the existing signal mechanism to make the latest props available as reactive values inside computed values and effects defined during setup? This would allow us to track props changes as dependencies without replacing callbacks on every render. What do you think about these two proposals? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
… effect() changes
Bundle size check
Compiler Diagnostics (tsc)
Compiler Diagnostics (typescript-go)
Reported by octocov |
HTTP Performance Benchmark
|
|
Hey @kotarotaniguchi0523! Thank you for the review. Both concerns make sense! But, I don't want to change the shape of a component to "a function that returns a render function". Hono JSX is based on the React-like syntax, and the new shape has its own pitfalls (forgetting
What do you think? |
|
Thank you for addressing my concerns! |
|
@kotarotaniguchi0523 Thank you. It was not a poor review at all! |
This PR introduces Signals to Hono JSX.
Until now, to add client-side interactivity, users have needed to use hooks from
hono/jsx/dom, which follow the React API. This is good, but there are two problems:I've been using Hono JSX, including its client-side features, since v4 was released. During that time, I realized I wanted a lighter client-side implementation.
The main use cases for Hono JSX are:
For these use cases, I think hooks are too heavy.
That's why I want to introduce Signals.
The Signals API is simple, and its implementation requires much less code compared to React-style hooks. I think Signals are a great fit for Hono JSX.
This PR introduces Signals as an experimental feature in v5. If we agree with this direction, I'd like to recommend using Signals over hooks.
We put a lot of effort into implementing hooks, so it might be sad to move away from them. However, I think this could be a good decision for long-term maintainability.
The following is an AI-generated description:
Adds signals for Hono JSX as an experimental feature.
signal,computed,effect,batchanduntrackedfromhono/jsx/signalhono/jsx/domupdates the text node or the attribute directly when a signal is passed as it is.valuein a component re-renders only that componentsignal(),computed()andeffect()in a component are kept for each instance. No hooks are neededeffect()in a component does not run on the serverhono/jsxandhono/jsx/domdo not importhono/jsx/signal. They detect a signal withSymbol.for('hono.signal')Breaking: the attribute types in
JSX.IntrinsicElementsare nowT | SignalLike<T>. Added todocs/MIGRATION.md.Size (minified):
hono/jsx/signalis 1.8 KB.hono/jsx/domgrows by 0.8 KB.The author should do the following, if applicable
pnpm run check:fixto format and lint the code