0.2.2 • Published 8 years ago

react-stateless v0.2.2

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

react-stateless

Helpers to write stateless functional components in React.

Write stateless functional components in React with lifecycle methods as pure functions!

ReactStateless.createClass(specification)

specification can be a stateless render function or an object containing pure stateless lifecycle functions.

Example: component as a function

import { React } from 'react';
import { createClass } from 'react-stateless';

function ComponentA(props) {
    return <div>{ props.name }</div>;
}

// React 0.14
export default ComponentA
// Or
export default createClass(ComponentA);

Example: component as an object

import { React } from 'react';
import { createClass } from 'react-stateless';

function shouldComponentUpdate(props, nextProps) {
    return props.name !== nextProps.name;
}

function render(props) {
    return <div>{ props.name }</div>;
}

export default createClass({shouldComponentUpdate, render})

Supported properties

  • propTypes
  • defaultProps
  • displayName (automatically detected by if your component function or render function is named)

Supported methods

  • componentWillMount(props)
  • componentDidMount(props, refs)
  • componentWillReceiveProps(props, nextProps, refs)
  • shouldComponentUpdate(props, nextProps, refs)
  • componentWillUpdate(props, nextProps, refs)
  • componentDidUpdate(props, prevProps, refs)
  • componentWillUnmount(props, refs)
0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago