-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support ssr #30
Conversation
@@ -374,7 +374,7 @@ const Overlay = React.forwardRef<HTMLDivElement, OverlayProps>((props, ref) => { | |||
// - react17 中,如果弹窗 mousedown 阻止了 e.stopPropagation(), 那么 document 就不会监听到事件,因为事件冒泡到挂载节点 rootElement 就中断了。 | |||
// - https://reactjs.org/blog/2020/08/10/react-v17-rc.html#changes-to-event-delegation | |||
useListener( | |||
document, | |||
typeof document !== 'undefined' ? document : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useListener 监听的对象是 null 是否还有意义?是否更合理的方式应该是没有 document 的情况下就不监听了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
下同
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没有的情况在useListener 的具体实现里已经存在了,这里不能动态的设置hooks方法吧,react的hooks按顺序存储,不能没有document的情况下就不执行吧?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你说的有道理
@@ -374,7 +374,7 @@ const Overlay = React.forwardRef<HTMLDivElement, OverlayProps>((props, ref) => { | |||
// - react17 中,如果弹窗 mousedown 阻止了 e.stopPropagation(), 那么 document 就不会监听到事件,因为事件冒泡到挂载节点 rootElement 就中断了。 | |||
// - https://reactjs.org/blog/2020/08/10/react-v17-rc.html#changes-to-event-delegation | |||
useListener( | |||
document, | |||
typeof document !== 'undefined' ? document : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你说的有道理
修复SSR下使用组件报错的问题