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(useFullscreen): replace the initial value with screenfull.isFullscreen #1755

Merged
merged 5 commits into from
Jul 18, 2022
Merged

fix(useFullscreen): replace the initial value with screenfull.isFullscreen #1755

merged 5 commits into from
Jul 18, 2022

Conversation

KangXinzhi
Copy link
Contributor

@KangXinzhi KangXinzhi commented Jul 11, 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 #1741

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English replace the initial value with screenfull.isFullscreen
🇨🇳 Chinese 初始值修改为 screenfull.isFullscreen

☑️ 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

@CLAassistant
Copy link

CLAassistant commented Jul 11, 2022

CLA assistant check
All committers have signed the CLA.

@KangXinzhi KangXinzhi changed the title fix(useFullscreen): optimize exitFullscreen methods fix(useFullscreen): replace the initial value with screenfull.isFullscreen Jul 13, 2022
@crazylxr crazylxr merged commit 472dd83 into alibaba:master Jul 18, 2022
@@ -17,7 +17,7 @@ const useFullscreen = (target: BasicTarget, options?: Options) => {
const onExitRef = useLatest(onExit);
const onEnterRef = useLatest(onEnter);

const [state, setState] = useState(false);
const [state, setState] = useState(Boolean(screenfull.isFullscreen));
Copy link
Collaborator

Choose a reason for hiding this comment

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

我觉得这里的默认是是有问题的。

screenfull 需要执行 screenfull.request(el) 绑定到具体的元素上,才会有实际意义的。初始化的时候都没有绑定,就没有实际意义吧。

另外 screenfull 是个单例,在所有 Hooks 是一致的,也就是如果写了两个 useFullscreen,那他们的初始化状态一定是一致的了。

如下示例,在新代码中出问题了:https://codesandbox.io/s/default-usage-forked-zg0cbw?file=/App.tsx

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.

None yet

4 participants