pablosichert / react-truncate

React component for truncating multi-line spans and adding an ellipsis.
https://www.webpackbin.com/bins/-Kw6QnAkjmv1OD6Of-ZD
ISC License
587 stars 129 forks source link

Truncate get error on 'width' prop when my app still work in another tab like keep-alive component #137

Open Sindr0me opened 4 years ago

Sindr0me commented 4 years ago

Hi, im working with iframe in tabs in my app. Every iframe is a separately react app. So I have a problem that when I leave from my tab with truncates components like that to another tab

          <Truncate
            onTruncate={param => {
              setTooltip(param);
            }}
            lines={truncateRows || 1}
            width={truncateOnWidth || 0}
            className="truncate-cell"
          >
            {value && value}
          </Truncate>

My app still works and has crashed with an error like this when the component has rerendered with newly uploaded data

_Uncaught Exception { name: "NS_ERROR_FAILURE", message: "", result: 2147500037, filename: "webpack-internal:///./nodemodules/react-truncate/lib/Truncate.js", lineNumber: 182, columnNumber: 0, data: null,

It's wrong only with prop 'width', If it prop have a value, the app will be crushed. So, I really confused about it.

p.s. my truncate cells will rerender sometimes because the new data can be uploaded anytime