Skip to content

Commit 8c8b92d

Browse files
authored
fix(ellipsisText): ellipsisRef.current may be null (#572)
1 parent d063692 commit 8c8b92d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/ellipsisText/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ const EllipsisText = (props: IEllipsisTextProps) => {
7878
* @return {*}
7979
*/
8080
const getStyle = (dom: NewHTMLElement, attr: string) => {
81+
if (!dom) {
82+
return null;
83+
}
8184
// Compatible width IE8
8285
// @ts-ignore
8386
return window.getComputedStyle(dom)[attr] || dom.currentStyle[attr];
@@ -203,7 +206,11 @@ const EllipsisText = (props: IEllipsisTextProps) => {
203206
* @return {*}
204207
*/
205208
const onResize = () => {
206-
const ellipsisNode = ellipsisRef.current!;
209+
if (!ellipsisRef.current) {
210+
return;
211+
}
212+
213+
const ellipsisNode = ellipsisRef.current;
207214
const parentElement = ellipsisNode.parentElement!;
208215
const rangeWidth = getRangeWidth(ellipsisNode);
209216
const containerWidth = getContainerWidth(parentElement);

0 commit comments

Comments
 (0)