@beisen/react-width-provider

react width provider add clientWidth to your Component props

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
@beisen/react-width-provider
Minified + gzip package size for @beisen/react-width-provider in KB

Readme

How To

import widthProvider from '@beisen/react-width-provider';

@widthProvider('width') //指定存在props中的key,如果不传,侧为width
class MyClass extends React.Component {
    render(){
        return <div style={{width: '50%'}}>
            数据会随着窗口大小的变化而变化
            {this.props.width}
        </div>
    }
}

export default MyClass

使用widthProvider包装过的组件,在this.props.中始终都能获取到自己的宽度

例子

git clone git@gitlab.beisencorp.com:ux-cnpm/ux-react-width-provider.git
cd ux-react-width-provider
npm install
npm run example

安装

npm install --save @beisen/react-width-provider

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.