Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
Read more and read less for paragraph in react

I want to add read-more and read-less functions to a paragraph using class

I am rendering components like this

<table border="1">
    <tbody>
      {data
        ? Object.keys(data).map((item) => {
            return (
              <tr key={"tr" + item}>
                {data[item]
                  ? Object.keys(data[item]).map((key) => {
                      return (
                        <td
                          key={"td" + key}
                          className={key === "description" && "read-more"}
                        >
                          {data[item][key]}
                        </td>
                      );
                    })
                  : null}
              </tr>
            );
          })
        : null}
    </tbody>
  </table>

And the output is this

<table border="1">
  <tbody>
    <tr>
      <td>New expense</td>
      <td>default</td>
      <td>10000</td>
      <td class="read-more">
        Long paragraph..
      </td>
    </tr>
    <tr>
      <td>New New exp</td>
      <td>default</td>
      <td>123</td>
      <td class="read-more">
        Long paragraph.. not displaying due to stack overflow too much code thing
      </td>
    </tr>
  </tbody>
</table>

So I am making many paragraphs using objects and this runs in other components too

So all I want is a function in which it for each or use any loop to get elements class named read-more and add function to it in which it creates an anchor tag for read-more and read-less by only using a class to p tag

Please solve my problem. Thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!