Skip to content

Support React.createFactory

Compare
Choose a tag to compare
@vzaidman vzaidman released this 20 Dec 15:50
· 405 commits to master since this release
  • Updated all packages on development.
  • Added tests and demos of React.cloneElement and React.createFactory.
  • We found out React.createFactory skipped the monkey patch we apply on React.createElement thus the following code didn't work:
import {lifecycle} from 'recompose';

const PostsList = ({ posts }) => (
  <ul>{posts.map(p => <li>{p.title}</li>)}</ul>
);

const PostsListWithData = lifecycle({
  componentDidMount() {
    fetchPosts().then(posts => {
      this.setState({ posts });
    })
  }
})(PostsList);
PostsList.whyDidYouRender = true;

because lifecycle uses React.createFactory to create it's child which is PostsList in this case:
https://github.com/acdlite/recompose/blob/master/src/packages/recompose/lifecycle.js