Socket
Book a DemoInstallSign in
Socket

@mg901/react-slot-fill

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mg901/react-slot-fill

![Travis (.org) branch](https://img.shields.io/travis/mg901/react-slot-fill/master.svg?style=flat-square)

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

React Slot Fill

Travis (.org) branch

Install

You can install this library via npm or yarn.

npm

npm i @mg901/react-slot-fill

yarn

yarn add @mg901/react-slot-fill

Use case

If you need to render a component from somepart of the DOM tree, but it needs to be visible in another part of the tree, this library solves it.

Usage

The usage is really simple:

toolbar.js

import React from 'react';
import { Slot, Fill } from '@mg901/react-slot-fill';

const Toolbar = (props) => (
  <div>
    <Slot name="Toolbar.Item" />
  </div>
);

export default Toolbar;

// single Fill
Toolbar.Item = (props) => (
  <Fill name="Toolbar.Item">
    <button>{props.label}</button>
  </Fill>
);

// or multiple Fill
Toolbar.Item = (props) => (
  <>
    <Fill name="Toolbar.Item">
      <button>{props.label}</button>
    </Fill>
    <Fill name="Toolbar.Item">
      <button>{props.label}</button>
    </Fill>
    <Fill name="Toolbar.Item">
      <button>{props.label}</button>
    </Fill>
  </>
);

feature.js

import React from 'react';
import Toolbar from './Toolbar';

const Feature = () => <Toolbar.Item label="My Feature!" />;

app.js

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from '@mg901/react-slot-fill';

import Toolbar from './Toolbar';
import Feature from './Feature';

const App = () => (
  <Provider>
    <Toolbar />
    <Feature />
  </Provider>
);

ReactDOM.render(<App />, document.getElementById('root'));

Props

Slot and Fill components use the same props, which are the following ones:

PropertiesTypesDefault ValueDescription
namestringnoneDetermines the name of the Slot/Fill.

License

MIT License

Copyright (c) 2018-2019 Maxim Alyoshin.

This project is licensed under the MIT License - see the LICENSE.md file for details.

Keywords

react

FAQs

Package last updated on 03 Jul 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.