passing-through
Version:
Pass properties and modifier functions to child context's which can modify children
62 lines (42 loc) • 1.33 kB
Markdown
The `passing-through` library is a component library that allows you to easily
transform child components through modifiers.
The module is released in the public npm registry and can be installed by
running:
```bash
npm install --save passing-through
```
The `passing-through` library exposes 2 components:
- [Pass](
- [Through](
```jsx
import { Pass, Through } from 'passing-through';
const modifiers = {
foo: [
function(props, passedProps, child) {
props.className = 'red';
console.log(passedProps) // { foo: true }
if (props.span) return <span>Changed</span>
}
]
}
<Pass foo modify={ modifiers }>
<Through span>
<div>
</Though>
</Pass>
// Renders <span className='red'>Changed</span>
```
The pass module used to configure the modifiers that get applied to children of
the [Through](
is the `modify` prop which stores the modifers that get applied.
The `modify` prop is an `object` where the key is the name of a property is
should trigger on, and the value an array of functions that need to be executed.
This component will apply all the modifications that are provided to the
[](
[](LICENSE)