paragon icon indicating copy to clipboard operation
paragon copied to clipboard

`Truncate` causes a JS error if a non-string child is passed

Open adamstankiewicz opened this issue 1 year ago • 0 comments

https://paragon-openedx.netlify.app/components/truncate/

In Truncate, children is expected to be a string.

However, by not supporting any type (string, node, etc.), we run the risk of having the component being flexible enough for consumers' use cases.

For example, if a consumer wants to bold some text in the paragraph of truncated text, they would not be able to in the current implementation.

image

Is there a way around this to have Truncate support HTML/React elements in its children? It looks like react-truncate also supports flexible children, maybe as inspiration.

adamstankiewicz avatar Aug 19 '22 11:08 adamstankiewicz