File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 11{
2- "version" : " 1.0.0 " ,
2+ "version" : " 1.0.1 " ,
33 "license" : " MIT" ,
44 "name" : " react-simple-hook-modal" ,
55 "description" : " A simple React modal with hook based API" ,
Original file line number Diff line number Diff line change @@ -12,11 +12,22 @@ export interface ModalProps {
1212 transition ?: ModalTransition ;
1313}
1414
15+ function hasDOM ( ) {
16+ return ! ! (
17+ typeof window !== 'undefined' &&
18+ window . document &&
19+ window . document . createElement
20+ ) ;
21+ }
22+
1523export const Modal : React . FC < ModalProps > = modal => {
16- const container = document . getElementById ( 'react-simple-modal-container' ) ;
1724 const { addOrUpdate, remove, getStaggerPixels } = useModalContext ( ) ;
1825 const { id, isOpen } = modal ;
1926
27+ const container = hasDOM ( )
28+ ? document . getElementById ( 'react-simple-modal-container' )
29+ : null ;
30+
2031 useEffect ( ( ) => {
2132 isOpen ? addOrUpdate ( id ) : remove ( id ) ;
2233 return ( ) => remove ( id ) ;
You can’t perform that action at this time.
0 commit comments