Advertisement · 728 × 90

Posts by Brandon McConnell

Preview
Shiki A beautiful yet powerful syntax highlighter

@antfu.me is there an officially recommended way to support dedent-like functionality in shiki.style?

hoping to add built-in dedent for code blocks without overriding shiki

1 week ago 0 0 0 0

Thanks! I emailed you

6 months ago 2 0 0 0

@adelfaure.bsky.social can i hire u for a new ascii project??

6 months ago 1 1 1 0

This is backward. How is canceling a debate promoting free speech?

Promoting free speech would mean promoting open debate. This is exactly the opposite.

6 months ago 0 0 0 0

where were you in the last presidential term where the left continually celebrated politicians, doctors, and reporters alike getting silenced and canceled?

if free speech died, it happened long before now

6 months ago 0 0 0 0

@t0nyyates.bsky.social can i be added to your list? would love for people to be able to find me on x that way

7 months ago 1 0 0 0

I'm happy to open an issue for this as well, except there's a fair chance I'm just doing something wrong. 😅

I really appreciate you maintaining such a great plugin. I know a lot of work goes into that. I'm happy to compensate you for any time spent on this if you like.

8 months ago 0 0 0 0
Video

@jamie.build Hi Jamie, I'm updating an app to Tailwind 4 and noticing with some of my dialog exit animations that the dialog briefly reappears after animating out. This only happens intermittently.

Any chance you'd be willing to take a look at this with me?

8 months ago 0 0 1 0
Advertisement

Yeah, that's how I've been doing it so far, but targeting specific elements would be pretty neat

9 months ago 0 0 1 0

@miriam.codes I was curious if you knew of any spec work being done on CSS nesting support inside of @keyframes, so we can do things like this:

@keyframes {
0% {
width: 0px;
> span {
opacity: 0%;
}
}
100% {
width: 50px;
> span {
opacity: 100%;
}
}
}

10 months ago 1 0 1 0

Yes, I actually made that switch right after sending you that message haha

Still, how would you avoid useEffect here, if you would? I'm waiting until the session is ready to know if the user is logged in or not.

10 months ago 0 0 0 0
Post image

@chance.dev I'm curious how you'd approach this pattern if you were trying to strip out this useEffect.
gist.github.com/brandonmccon...

If a user is logged in, the root should redirect them to `/dashboard`. Otherwise, it redirects them to `/home`.

10 months ago 0 0 1 0

Yes, a lot of this boils down to the desire for nested components.

I generally advocate for separating concerns and moving complex logic into new components, but I often have to do this for a simple conditional and nested pieces of composition simply to hold state.

I’d love nesting!

Thanks again!

11 months ago 1 0 0 0

BUILD PLUGIN (4/4)

This approach seems to have the fewest gotchas and simplifies the syntax, making it feel more native.

My biggest hesitation with this approach is that I believe in “Just JavaScript,” and while this would be JS, it feels more magical since it happens outside of React.

11 months ago 2 0 1 0

BUILD PLUGIN (3/4)

Immediately, I could replace that <$> wrapper with a familiar-feeling string directive, like 'use render' (or similar).

Any block using that directive would immediately be broken out into a separate component.

11 months ago 2 0 1 0

BUILD PLUGIN (2/4)

Something great about this approach is that as long as the pre-compilation is robust and works effectively, I could simplify the syntax even further.

Right away, we remove the need to use a callback; we can simply match any content wrapped in syntax like <$> and expand that.

11 months ago 2 0 1 0

BUILD PLUGIN (1/4)

e.g. Vite/Webpack/etc.

In this approach, I would pre-compile any uses of this <$> syntax and *actually* break its usage out into separate functional components within the same file.

Natural hoisting makes this even easier because we don’t have to worry about order.

11 months ago 2 0 1 0

PROXIES

With the proxies approach, instead of passing the hooks themselves to the callback, I would pass a proxy that watches how the hook is used and somehow carries that usage back to the component instance itself, outside the callback.

I’m not sure how difficult (or possible) that is.

11 months ago 2 0 1 0
Advertisement

I think for v1 to actually make sense, I clearly need to change something here to support or align with React’s Rules of Hooks, which most of these appear to break.

I have two defining ideas—
– proxies
– build plugin

11 months ago 2 0 1 0

Because my implementation goes a bit deeper than those others, I can do some things to optimize usage within the package, like auto-memoization, striving to follow the same patterns as the compiler.

11 months ago 2 0 1 0

There are countless solutions and packages out there trying to solve this same problem, so it’s definitely a pain point felt in the framework that I think the core team could tackle in an equally or more elegantly.

11 months ago 2 0 1 0

I’m not as knowledgeable as you in the compiler’s inner workings.

My primary objective here was to tackle this problem with an approach that ensures the hooks are initialized and used in the same render cycle, which they appear to be, but I can see how it might still violate the rules.

11 months ago 2 0 1 0

I agree that sticking to what is recommended as best practice should be promoted here.

Thinking through my implementation, it does feel like a pattern that React Compiler could officially support with the proper affordances.

11 months ago 2 0 1 0

Thanks, Dan! I really appreciate your thoughtful feedback here.

Do you happen to have a concrete example you could share that I could test around for where this would likely break?

My implementation is different than the usual `children()` approach, but I’m sure it hits the same limitations.

11 months ago 2 0 1 0

And if you would rather not discuss it on X, I’m happy to continue that conversation right here in this thread on Bluesky

TY 🙏🏼

11 months ago 3 0 1 0
Preview
Joe Savona on X: "@branmcconnell It's great to see experimentation in this space and I'm super hesitant to chime in and ruin the parade. But just a heads up that this does break the Rules of Hooks since it's passing hooks as first-class values, so code using this library won't get compiled by React Compiler." / X @branmcconnell It's great to see experimentation in this space and I'm super hesitant to chime in and ruin the parade. But just a heads up that this does break the Rules of Hooks since it's passing hooks as first-class values, so code using this library won't get compiled by React Compiler.

Here is the most relevant message from Joe Savona over there:
x.com/en_js/status...

The conversation has progressed past that point into a few tangential conversations and DMs, but I think addressing and discussing the concern there would be fitting, both for my package and that article I shared^

11 months ago 2 0 1 0
Preview
Calling React Hooks Conditionally/Dynamically Using Render Props If you've used hooks at all, you'll know that one limitation is not being able to conditionally call them in the render body of your component. So what can we do if we really need to call a hook condi...

There’s one engineer from Meta, who chimed in, convinced that this violates Rules of Hooks, but based on my understanding of the documentation, I don’t think it should.

This article’s implantation is nearly identical and makes the same non-violation claim:
unsplash.com/blog/calling...

11 months ago 2 0 1 0
Advertisement

@danabra.mov the conversation is happening on X, but I was hoping you could clear something up for me?

We’re having a discussion about Rules of Hooks, specifically using hooks inside of a render prop so the hooks are contained in the same render cycle, not passed between components

11 months ago 3 0 1 0

I can't share the full codebase yet (at least, without probably a BAA), but I can share the components that are failing to render in case that clearly points us toward the issue

DM'ing you

11 months ago 0 0 0 0

For context, I am not using `$effect` anywhere on in my app.

Turning off my excluded directories when searching my codebase, the only places `$effect` appears are in root.svelte, the file svelte generates at `[ROOT]/.svelte-kit/generated/root.svelte`

11 months ago 0 0 1 0