Socket
Book a DemoInstallSign in
Socket

composens

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

composens

A name spaced compose function to avoid prop collision

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

composeNS

Namespaces are one honking great idea -- let's do more of those!

composeNS is namespaced compose function that can be used with recompose to avoid prop name collision.

build status npm version npm downloads

Usage

compose(
  opts: string | { namespace: string, propMap: Array<string> | { [string]: string } },
  ...functions: Array<Function>,
): Function

Usage to namespace a portion of a group of HOC

import ReactDOM from 'react-dom'
import { compose, withProps, mapProps, withState } from 'recompose';
import composeNS from 'composens';

const App = compose(
  withState('state', 'setState', { location: 'france' }),
  composeNS(
    {
      namespace: 'toulon',
      propMap: { 'state': 'parentState' }, // you can still access props passed in using a the propMap option that is a array of props you want passed in, or an object `{ key: alias }`
    },
    withState('state', 'setState', { prisoner: 24601 })
    mapProps(props => ({ description: `location: ${props.parentState.location}, prisoner: ${props.state.prisoner}` }))
  )
)((props) => <div>description: {props.toulon.description}</div>);

ReactDom.render(<App />, document.querySelector('#container'));

Keywords

react

FAQs

Package last updated on 11 Oct 2017

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