Using npm:
npm install --save react-showhide-componentor using yarn:
yarn add react-showhide-componentimport React, { Component } from 'react'
import ReactShowHideComponent from 'react-showhide-component'
const arr = [1, 2, 3, 4, 5];
export default class Example extends Component {
render() {
const listHtml = arr.map((elem, i) => {
return <div key={i}>{elem}</div>;
});
return <ReactShowHideComponent items={listHtml} minItems={2} />;
}
}| Property | Type | Default | Description |
|---|---|---|---|
items |
string | array | undefined | Array of elements of string |
minItems |
number | undefined | No of element(for array) / lines (for string) to show by default |
mode |
string | array | 'array' or 'string' |
viewMoreButton |
element | View More |
View more button |
viewLessButton |
element | View Less |
View less button |
MIT © https://github.com/vaibhavdiwani
Any help in improvement/optimization is very much appreciated