Skip to content

Commit

Permalink
fix: Crash on missing method
Browse files Browse the repository at this point in the history
  • Loading branch information
gpalsingh committed Sep 6, 2024
1 parent fbe4d75 commit d5eee2b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@commutatus/react-arrows",
"version": "1.2.1",
"version": "1.2.2",
"description": "React SVG arrow between two HTML elements",
"keywords": [
"arrow",
Expand Down
14 changes: 9 additions & 5 deletions src/hooks/useArrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ const useArrow = ({ className, head, from, to, onChange, onClick }) => {
const arrowRef = useRef();

useLayoutEffect(() => {
if (!arrowRef.current) return
arrowRef.current.setProps({
className, head, from, to, onChange, onClick
})
if (!arrowRef.current?.setProps) return
try {
arrowRef.current.setProps({
className, head, from, to, onChange, onClick
})
} catch (e) {
console.error(e)
}
}, [className, head, from, to, onChange, onClick])

useLayoutEffect(() => {
Expand All @@ -33,7 +37,7 @@ const useArrow = ({ className, head, from, to, onChange, onClick }) => {
onChange,
onClick
})
} catch(e){
} catch (e) {
console.warn(e);
return;
}
Expand Down

0 comments on commit d5eee2b

Please sign in to comment.