JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15
  • Score
    100M100P100Q32522F
  • License MIT

Minimalistic react components

Package Exports

  • react-mini
  • react-mini/pure

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-mini) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-mini Build Status

Create minimalistic react components

For inline components or if you are really lazy.

Install

$ npm install --save react-mini

Usage

var React = require('react');
var mini = require('react-mini');


module.exports = mini( props => <h1>Title: {props.title}</h1> );
module.exports = mini( ({ title }) => <h1>Title: {title}</h1> );
module.exports = mini( ({ hidden = false, title }) => !hidden?<h1>Title: {title}</h1>:null );
module.exports = mini( ({ greet = 'Hi', name }) => <h1>{greet} {name}</h1> );

Pure components

Create pure components using PureRenderMixin

var React = require('react');
var pure = require('react-mini/pure');

module.exports = pure( ({ title }) => <h1>Title: {title}</h1> );

with props and state

var Counter = mini( ({ step = 1 } , { setState, state: { count } }) => { 
    var incCounter = () => setState({ count : count + step });

  return <span>Counter: {count}<button onClick={incCounter}>+1</button></span> 
}, { count: 10 }); // <= initialState

React.render(
  <Counter step={10}/>,
  document.body
)

API

mini(render:Function(props, component), [initialState:Object])

  • render : This is the actual render function.
    • props:Object : The props of the component
    • component:Object : The component (this)
  • initialState : The initial state of the component.

License

MIT © Christoph Hermann