exah / nano-slots Goto Github PK
View Code? Open in Web Editor NEWA super lightweight slots implementation for React
License: MIT License
A super lightweight slots implementation for React
License: MIT License
The package peerDeps specify react 16/17 only.
This fails on recent npm unless --legacy-peer-deps
is used.
I am here to say Thank You for the awesome package @exah
I'm pretty sure there are issues with the way that null state is tracked for Slots.
This issue came up in two specific situations.
The Fill frequently needs to access data from the Slot to render correctly, so not having some means of doing that(similar to params in react-view-slot
) is problematic for our use case.
Is there some way to achieve this that I'm missing?
Hello,
We use react-router v6 which supports relative links. In order to make it works properly the components need to behave like they do when rendered as a Portal. So no matter where they are physically rendered in the DOM they still follow the virtual tree structure and have access to any context wrapping them.
I noticed that this library is breaking this behaviour, so we can't use relative links in components "sent" in our Layout.
Do you think there could be a way to match Portals in term of Context consumption?
I see that you have onChange, but it doesn't get called on the initial render. Is passing context up the tree from the components that render the fills the only method I can use to figure out if a slot has something in it?
Hello, thank you for this library. I am switching from react-fill-slots library to yours, because of keeps updating with the new ReactJs version. I am trying to solve one problem. Let me give you an example.
This is my component where I am using Fill with name Sidebar.Content
`export default function Sidebar({ label, order, children, renderDontFill = false }) {
const content = (
<Section order={order}>
<Header>{label}</Header>
{children}
</Section>
);
return renderDontFill ? content : <Fill name="Sidebar.Content">{content}</Fill>;
}`
This is my component where I am using <Slot name="Sidebar.Content>
function Sidebar() {
<SlotsProvider>
<Slot name="Sidebar.Content">
{(elements) => (
<div>
{elements.sort((l, r) => (l.props.order || 1000) - (r.props.order || 1000))}
</div>
)}
</SlotsProvider>
);
}
if content In Sidebar is more than one it always displays the last one. In previous library react-slot-fill there is functionality of getting byName which returns Fill[] . Is there a way to solve this with your library ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.