# react-slot-props

> > slot slot slot , react slot!

Latest version **0.1.20** (published 2019-06-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-slot-props
pnpm add react-slot-props
yarn add react-slot-props
bun add react-slot-props
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.20 |
| Published | 2019-06-11 |
| First published | 2018-09-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 32.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | janryWang |
| Maintainers | janrywang |

## Links

- npm: https://www.npmjs.com/package/react-slot-props
- Repository: https://github.com/janryWang/react-jsx-props
- Homepage: https://github.com/janryWang/react-jsx-props#readme
- Issues: https://github.com/janryWang/react-jsx-props/issues
- npm.io page: https://npm.io/package/react-slot-props

## Dependencies (3)

- [raf](https://npm.io/package/raf.md) ^3.4.0
- [case](https://npm.io/package/case.md) ^1.5.5
- [lodash.get](https://npm.io/package/lodash.get.md) ^4.4.2

## Recent versions

- 0.1.20 (latest) — 2019-06-11
- 0.1.19 — 2019-04-04
- 0.1.18 — 2019-04-03
- 0.1.17 — 2019-01-10
- 0.1.16 — 2018-11-05
- 0.1.15 — 2018-11-05
- 0.1.14 — 2018-11-05
- 0.1.13 — 2018-10-12
- 0.1.12 — 2018-10-11
- 0.1.11 — 2018-10-08
- 0.1.10 — 2018-09-27
- 0.1.9 — 2018-09-20
- 0.1.8 — 2018-09-20
- 0.1.7 — 2018-09-20
- 0.1.6 — 2018-09-20
- … 6 more at https://npm.io/package/react-slot-props/versions

## README

# react-slot-props

> slot slot slot , react slot!

### Usage

```jsx
import React, { useEffect, useState } from 'react'
import ReactDOM from 'react-dom'
import { createSlotComponents } from 'react-slot-props'

const Home = createSlotComponents(
  ({ slot }) => {
    return (
      <div>
        {slot.render('areas.header.areas.logo', render =>
          render({
            innerData: 'This is Logo,'
          })
        )}
        {slot.render('areas.header.areas.nav.elements',(render,props)=>{
          return props.title
        })}
        {slot.render('areas.body')}
      </div>
    )
  },
  [
    {
      type: 'Home',
      root: true,
      areas: ['Header', 'Body', 'Footer']
    },
    {
      type: 'Header',
      areas: ['Logo', 'Nav']
    },
    {
      type: 'Logo'
    },
    {
      type: 'Nav',
      elements: ['Element']
    },
    {
      type: 'Element'
    },
    {
      type: 'Body'
    }
  ]
)

const Wrapper = props => {
  const [visible, setState] = useState(true)
  useEffect(() => {
    setTimeout(() => {
      setState(false)
    }, 2000)
  })
  return visible ? props.children : <React.Fragment />
}

const NavItem = (props) => {
  const [title, setTitle] = useState(props.title)
  // useEffect(() => {
  //   setTimeout(() => {
  //     setTitle('123123123123')
  //   }, 1000)
  // })
  return <Home.Element title={title} />
}

const App = () => {
  const [columns, setColumns] = useState([])
  useEffect(() => {
    setTimeout(() => {
      setColumns([1, 2, 3, 4])
    },1000)
  }, [])
  return (
    <Home>
      <Home.Header>
        <Home.Nav>
          {columns.map(key => {
            return <NavItem key={key} title={key} />
          })}
        </Home.Nav>
        <Home.Logo>{({ innerData }) => <div>{innerData}</div>}</Home.Logo>
      </Home.Header>
      <Wrapper>
        <Home.Body>{() => <div>This is Body</div>}</Home.Body>
      </Wrapper>
    </Home>
  )
}

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

### API

**`createSlotComponents(RootComponent : Function,relations :Array<Relation>) : Function`**

```javascript
type Relations {
    type : String
    areas: Array<String>
    elements: Array<String>
    root : boolean
}
```

### Install

```
npm install --save react-slot-props
```

### LICENSE

The MIT License (MIT)

Copyright (c) 2018 JanryWang

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---
_Source: https://npm.io/package/react-slot-props · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
