react-showhide-component
v1.0.2
Published
React component for view more/view less functionalities.
Downloads
4
Maintainers
Readme
react-showhide-component
Install
Using npm:
npm install --save react-showhide-component
or using yarn:
yarn add react-showhide-component
Usage
import 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} />;
}
}
Props
| 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 |
License
MIT © https://github.com/vaibhavdiwani
Any help in improvement/optimization is very much appreciated