Skip to content

Automatically scrolls a component to the bottom, unless the user has scrolled up.

License

Notifications You must be signed in to change notification settings

thk2b/autoscroll-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-autoscroll

Autoscroll a react component

install

npm install --save react-autoscroll

usage

import React from 'react'
import Autoscroll from 'react-autoscroll'

class MyList extends React.Component {
    render(){
        const { items, ...props } = this.props
        return (
            <ul { ...props } >{ // You MUST pass down props
                items.map(
                    item => <Item 
                        key={ item.id } 
                        {...item}
                    />
                )
            }</ul>
        )
    }
}

export default Autoscroll(MyList)

Autoscroll(Component): returns the passed component without any additional markup. It scrolls the root node rendered by the component to the bottom whenever it updates, but not if the user has scrolled up.

⚠️ You must Explicitly pass down props to the wrapped component. ⚠️

About

Automatically scrolls a component to the bottom, unless the user has scrolled up.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published