New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-purify

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-purify

helper functions and decorators for purification of react components with global dependencies and context. Simplifies the implementation of a flux-architecture

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

react-purify

This handy ES7 decorators makes it easy to implement (or migrate gradually) your react-components to a flux-like architecture. Goal of this library is empowering users to purify components quickly without breaking existing architectures.

mixins :

import {pure,mix} form 'react-purify'

@pure() // pureRenderMixin
class MyPureComponent extends React.Component {
 //...
}

//if you need more mixins :
@mix([LinkedStateMixin,PureRenderMixins,...])
class MyComp {
  //...
}

ready to use component-factories

import {UI,pureUI} form 'react-purify'

const MyPureComponent = pureUI( p=> (<h1>{p.title} </h1>) ); 
const MyImpureComponent = UI( p=>(<h1> {globalState} </h1>) );

context-helpers


var appState={todo:[/*...*/]};

import {inject,use} form 'react-purify'

@inject({appState}) // or @inject({appState:appState})
class TodoApp {
  render(){
     return <TodoList />
  }
}

@use( // transfers context to props
  ['appState'], //get the appState
  p=>({ //extract component dependencies
    todo:p.appState.todo
  })
)
@pure() // lets only redraw if todos have changed
class TodoList {
  render(){
     return <ul>{this.props.todo.map( (todo,k)=> <li key={k} >{todo}</li> )}</ul>
  }
}

//The example above shows how you can gradually move dependencies. Following code is equivallent :

@inject({appState}) 
@use(['appState'],p=>(
  {todo:p.appState.todo})
) 
class TodoApp {
  render(){
     return <TodoList {...this.props.todo}/>
  }
}

@pure()
class TodoList {
  render(){
     return <ul>{this.props.todo.map( (todo,k)=> <li key={k} >{todo}</li> )}</ul>
  }
}

Keywords

FAQs

Package last updated on 31 Aug 2015

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc