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

Performance optimize option: splitEveryChars #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

orloffv
Copy link

@orloffv orloffv commented May 7, 2019

in my case - string of 10,000 characters without spaces(word-break: break-all;)
render takes twenty seconds

@CezaryDanielNowak
Copy link
Owner

Hi, sorry for late reply.
What is the functional difference between splitEveryChars true and false?

@orloffv
Copy link
Author

orloffv commented Jul 10, 2019

roblem is when there are a lot of characters without spaces. the function works very slowly(seconds)

now it is possible to iterate through a few characters

@CezaryDanielNowak
Copy link
Owner

I see. So maybe let's make it a default behavior and don't introduce splitEveryChars prop at all

@orloffv
Copy link
Author

orloffv commented Jul 10, 2019

Maybe, but I have this problem only with big texts and without delimiters.
My solution has limitations. Clipped text every n characters. The default is not pretty. Only for cases when valid data such

@CezaryDanielNowak
Copy link
Owner

CezaryDanielNowak commented Jul 10, 2019

Did you try css solution?

white-space: pre-wrap;
word-wrap: break-word;

Alternatively maybe it's worth to preprocess text before clamping it with react-dotdotdot?

Like that (this code is just an example, not production ready):

<Dotdotdot>
  <p>{ contents.split(' ').map((val) => val.split(/(.{20})/).filter(Boolean).join(' ') ).join(' ') }</p>
</Dotdotdot>

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

Successfully merging this pull request may close these issues.

2 participants