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 19, 2024
1 parent 14e0e82 commit f8feb3e
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ export const IndividualResource = ({
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 f8feb3e

Please sign in to comment.