nihgwu / create-slots

Bring slots to React component
create-slots.vercel.app
MIT License
96 stars 0 forks source link

React Server Components Compatibility #22

Open jlarmstrongiv opened 1 year ago

jlarmstrongiv commented 1 year ago

Server Components are being added to React:

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

nihgwu commented 1 year ago

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