Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
/* eslint-disable react/prop-types */import React, { useState } from 'react'import parse from "html-react-parser";const FeedDescription = ({ ownerDescription }) => {const [isReadMoreActive, setIsReadMoreActive] = useState(false);const readMoreHandler = () => setIsReadMoreActive(!isReadMoreActive)const htmlParsedText = (fullStringText) => {const fullText = parse(fullStringText)if (fullStringText.length > 500) {const shortenedString = fullStringText.substr(0, 500);const shortenedText = parse(`${shortenedString}... `);return (<p>{isReadMoreActive ? fullText : shortenedText}<span className='cursor-pointer' onClick={readMoreHandler}>{isReadMoreActive ? " Leer menos" : " Leer más"}</span></p>);}return <p>{fullText}</p>};return (<div className="show-read-more">{htmlParsedText(ownerDescription)}</div>)}export default FeedDescription