Skip to content

Commit e28c5a3

Browse files
committed
fix: adding extra guard to check reference is available
Bug noticed during PR review, however I was unable to reproduce it locally. Adding this check ensures that we arent getting the bounding client rects on a null ref.
1 parent 546948c commit e28c5a3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/components/JustNotSorry.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const JustNotSorry = ({ onEvents, phrases }) => {
4848
observer,
4949
]);
5050

51-
if (warnings.length > 0) {
51+
if (email.current != null && warnings.length > 0) {
5252
const currentEmail = email.current;
5353
const parentRect = currentEmail.offsetParent.getBoundingClientRect();
5454
const warningComponents = warnings.map((warning, i) => {
@@ -65,7 +65,15 @@ const JustNotSorry = ({ onEvents, phrases }) => {
6565
offsetLeft + warning.endOffset
6666
}`;
6767
}
68-
return <Warning key={key} textArea={parentRect} range={warning.rangeToHighlight} message={warning.message} number={i} />;
68+
return (
69+
<Warning
70+
key={key}
71+
textArea={parentRect}
72+
range={warning.rangeToHighlight}
73+
message={warning.message}
74+
number={i}
75+
/>
76+
);
6977
});
7078
return ReactDOM.createPortal(warningComponents, currentEmail.offsetParent);
7179
}

0 commit comments

Comments
 (0)