Skip to content

Performance optimize option: splitEveryChars - #46

Open
orloffv wants to merge 1 commit into
CezaryDanielNowak:masterfrom
orloffv:orloffv.splitEveryChars
Open

Performance optimize option: splitEveryChars#46
orloffv wants to merge 1 commit into
CezaryDanielNowak:masterfrom
orloffv:orloffv.splitEveryChars

Conversation

@orloffv

@orloffv orloffv commented May 7, 2019

Copy link
Copy Markdown

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

@CezaryDanielNowak

Copy link
Copy Markdown
Owner

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

@orloffv

orloffv commented Jul 10, 2019

Copy link
Copy Markdown
Author

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
Copy Markdown
Owner

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

@orloffv

orloffv commented Jul 10, 2019

Copy link
Copy Markdown
Author

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

CezaryDanielNowak commented Jul 10, 2019

Copy link
Copy Markdown
Owner

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