Skip to content
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

fix: handleResize never perform in React 18 strictMode #1929

Merged
merged 5 commits into from Dec 19, 2022

Conversation

hchlq
Copy link
Collaborator

@hchlq hchlq commented Oct 19, 2022

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

close #1910

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@hchlq hchlq requested a review from crazylxr October 19, 2022 12:09
@hchlq
Copy link
Collaborator Author

hchlq commented Oct 19, 2022

项目依赖的 React 不是 18 ,不太好加单侧,改动点的影响:在 18 以下的版本对原来的逻辑不会有影响,在 18 的情况下增加一个监听逻辑而已。

@miracles1919
Copy link
Collaborator

感觉得专门弄个 react 18 的 CI

@CLAassistant
Copy link

CLAassistant commented Nov 25, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@miracles1919 miracles1919 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在原本的 useEffect 里改是不是更简单点

useEffect(() => {
  if (!isBrowser) return;
  if (!listening) {
    window.addEventListener('resize', handleResize);
  }
  // ...
}, [])

@crazylxr crazylxr merged commit d0b7793 into alibaba:master Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useResponsive在cra的项目里如果文件没有import React无法正常工作
4 participants