![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
react-slot-fill
Advanced tools
Slot & Fill component for merging React subtrees together.
npm install react-slot-fill --save
git clone https://github.com/camwest/react-slot-fill
cd react-slot-fill
npm start
Note These examples use React Fiber Alpha
import { Slot, Fill } from 'react-slot-fill';
const Toolbar = (props) =>
<div>
<Slot name="Toolbar.Item" />
</div>
export default Toolbar;
Toolbar.Item = (props) =>
<Fill name="Toolbar.Item">
<button>{ props.label }</button>
</Fill>
import Toolbar from './Toolbar';
const Feature = () =>
[
<Toolbar.Item label="My Feature!" />
];
import Toolbar from './Toolbar';
import Feature from './Feature';
import { Provider } from 'react-slot-fill';
const App = () =>
<Provider>
<Toolbar />
<Feature />
</Provider>
ReactDOMFiber.render(
<App />,
document.getElementById('root')
);
Creates a Slot/Fill context. All Slot/Fill components must be descendants of Provider. You may only pass a single descendant to Provider
.
interface Provider {
/**
* Returns instances of Fill react components
*/
getFillsByName(name: string): Fill[];
/**
* Return React elements that were inside Fills
*/
getChildrenByName(name: string): React.ReactChild[];
}
getFillsByName
and getChildrenByName
are really useful for testing Fill components.
See src/lib/__tests/Provider.test.tsx for an example.
Expose a global extension point
import { Slot } from 'react-slot-fill';
interface Props {
/**
* The name of the component. Use a symbol if you want to be 100% sue the Slot
* will only be filled by a component you create
*/
name: string | Symbol;
/**
* Props to be applied to the child Element of every fill which has the same name.
*
* If the value is a function, it must have the following signature:
* (target: Fill, fills: Fill[]) => void;
*
* This allows you to access props on the fill which invoked the function
* by using target.props.something()
*/
fillChildProps?: {[key: string]: any}
/**
* A an optional function which gets all of the current fills for this slot
* Allows sorting, or filtering before rendering. An example use-case could
* be to only show a limited amount of fills.
*
* By default Slot injects an unstyled `<div>` element. If you want greater
* control over presentation use this function.
*
* @example
* <Slot name="My.Slot">
* {(items) => <Component>{items}</Component>}
* </Slot>
*/
children?: (fills) => JSX.Element
}
Render children into a Slot
import { Fill } from 'react-slot-fill';
interface Props {
/**
* The name of the slot that this fill should be related to.
*/
name: string | Symbol
/**
* one or more JSX.Elements which will be rendered
*/
children: JSX.Element | JSX.Element[]
}
You can add additional props to the Fill which can be accessed in the parent node of the slot via fillChildProps.
FAQs
Unknown package
The npm package react-slot-fill receives a total of 8 weekly downloads. As such, react-slot-fill popularity was classified as not popular.
We found that react-slot-fill demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.