GitShow/developit/preact-slots
developit

preact-slots

๐Ÿ•ณ Render Preact trees into other Preact trees, like portals.

by developit
preactpreact-components
Star on GitHubForkWebsitenpm

JavaScript

156 stars3 forks2 contributorsQuiet ยท 6y agoSince 2018

Meet the team

See all 2 on GitHub โ†’
developit
developit9 contributions
greenkeeper[bot]Bot
greenkeeper[bot]1 contribution

Languages

View on GitHub โ†’
JavaScript100%

Commit activity

Last 12 weeks ยท 0 commits

Full graph โ†’

Community health

1 of 6 standards met

Community profile โ†’
28
โœ“READMEโ—‹Licenseโ—‹Contributingโ—‹Code of Conductโ—‹Issue Templateโ—‹PR Template

Recent PRs & issues

Quiet ยท 4 in progress ยท Last activity 6y ago
See all on GitHub โ†’
fwilkerson
Allow for multiple Slots and add ability to render multiple childrenOpenPR

The library did not appear to work as intended. I could only get it to work for a single slot and only if I was rendering 1 child in the slot content. After some debugging I noticed two issues; Slots share the same state, settings state on a second slot override the first slots content It was always choosing children[0] when evaluating children/content Since all slots shared the same state.content I decided to key the content by the slots name. I also noticed the onChange functions were being called even when the slot in question was not changing. This was due to onChange being an array of update functions and each update was executed when a SlotContent changed. So I applied the same idea to onChange, it is now an object, the key is the slots name and the value is the update function. To address the issue of only being able to render a single child within SlotContent, I updated it to send all of it's children to apply. Then when slot renders the content it will determine if it should pass all the children, or just render the zero node (in the case of a string being the content). A working demo with the updates I've made can be found here. Switch the imports for preact-slots to the released version to see the issues.

fwilkerson ยท 7y ago
Structured data for AI agents

Repository: developit/preact-slots. Description: ๐Ÿ•ณ Render Preact trees into other Preact trees, like portals. Stars: 156, Forks: 3. Primary language: JavaScript. Languages: JavaScript (100%). Homepage: https://npm.im/preact-slots Topics: preact, preact-components. Open PRs: 4, open issues: 3. Last activity: 6y ago. Community health: 28%. Top contributors: developit, greenkeeper[bot].

ยท@ofershap

Replace github.com with gitshow.dev