Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import { createElement } from 'react';
  2. import { compose } from 'ramda';
  3. import { lifecycle, withProps } from 'recompose';
  4.  
  5. const enhance = compose(
  6. lifecycle({ componentDidMount() {
  7. this.refs.node.scrollIntoView({block: 'end', behavior: 'smooth'});
  8. } }),
  9. withProps({ ref: 'node' }),
  10. );
  11.  
  12. const autoScroll = Component => ({ ref, ...props }) =>
  13. createElement('div', { ref }, createElement(Component, props));
  14.  
  15. export default compose(enhance, autoScroll);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement