Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Show Additional Text #104

Open
lisaWriteJava opened this issue Mar 10, 2022 · 1 comment
Open

How to Show Additional Text #104

lisaWriteJava opened this issue Mar 10, 2022 · 1 comment

Comments

@lisaWriteJava
Copy link

lisaWriteJava commented Mar 10, 2022

When I click the show more the additional text doesn't show. It seems to reload the page

@hotgeart
Copy link

You can't.

But you can hack your way. When you click, you change the line to a ridiculous number.

const [line, setLine] = useState(2);

<TextTruncate
  line={line}
  element="span"
  truncateText="…"
  text={ user.description }
  textTruncateChild={<button onClick={()=>{ setLine(9999999999) }}>I want mooooore</button>}
/>

Or you just hide the real text and when you click, you show the real one and hide the truncated one.

const [showText, setShowText] = useState(false);

{showText ? (
  <>
    {user.description}
  </>
) : (
  <TextTruncate
    line={2}
    element="span"
    truncateText="…"
    text={user.description}
    textTruncateChild={<button onClick={() => { setShowText(true) }}>I want mooooore</button>}
  />
)}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants