create-slots icon indicating copy to clipboard operation
create-slots copied to clipboard

React Server Components Compatibility

Open jlarmstrongiv opened this issue 2 years ago • 1 comments

Server Components are being added to React:

  • https://github.com/reactjs/rfcs/pull/188
  • https://beta.nextjs.org/docs/rendering/server-and-client-components

Server Components must avoid Client Component APIs, such as useEffect, etc. Some shared APIs like forwardRef and useId are compatible between both environments.

I like the create-slots package. It fills the gap I missed when working with Vue and Web Components—a slots API.

Can create-slots be updated to work in the Server Components environment, or will that break the rendering you described in the RFC?

Checkout the console.log you will find how clean it will be if it's built in React core, as in user space we have no way to know the index when inserting an item, so I have to rescan the children of a host, then it results in lots of force update

jlarmstrongiv avatar Apr 02 '23 06:04 jlarmstrongiv

I'm afraid unless it's a builtin feature in React, it's impossible to get rid of useContext and useEffect

nihgwu avatar Apr 03 '23 19:04 nihgwu