Skip to content

Commit

Permalink
Throw an error if IndividualResource cannot be rendered
Browse files Browse the repository at this point in the history
With the current code, this condition will always fail. Prevent this
from silently passing and instead raise an error.
  • Loading branch information
victorlin committed Nov 14, 2024
1 parent 9ab5067 commit 25341ae
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,11 @@ export const IndividualResource = ({resource, isMobile}: IndividualResourceProps
const ref = useRef<HTMLDivElement>(null);
const [topOfColumn, setTopOfColumn] = useState(false);
useEffect(() => {
// don't do anything if the ref is undefined or the parent is not a div (IndividualResourceContainer)
if (!ref.current
|| !ref.current.parentNode
|| ref.current.parentNode.nodeName != 'DIV') return;
if (ref.current === null ||
ref.current.parentNode === null ||
ref.current.parentNode.nodeName != 'DIV') {
throw new InternalError("ref must be defined and the parent must be a div (IndividualResourceContainer).");
}

/* The column CSS is great but doesn't allow us to know if an element is at
the top of its column, so we resort to JS */
Expand Down

0 comments on commit 25341ae

Please sign in to comment.