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

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚧 At this stage, this project is not unit-tested but works as expected. Use with caution. 🚧

autoscroll-react

Autoscroll a react component

npm version Open Source Love

install

npm install --save autoscroll-react

usage

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

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