Indexlist component based better-scroll for react。
npm install react-indexlist --save
or yarn add react-indexlist
import IndexList from 'react-indexlist';
import 'react-indexlist/dist/index.css';
handleSelect = (item) => {
console.log(item);
}
<IndexList data={arr} onSelect={this.handleSelect} className="my-indexlist" />
propTypes: {
// className of component
className: PropTypes.string,
// Array of list
data: PropTypes.array.isRequired, // Default: Array<{ title: string, items: array<{ name: string }> }>
// render item by self, return ReactNode
renderItem: PropTypes.func, // function (item)
// onClick item callback
onSelect: PropTypes.func, // function (item)
}