-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Roadmap | ||
|
||
## v1 Version (Current Version) \{#v1-version} | ||
|
||
> The functionalities are basically complete. Future work will focus on iterations over existing hooks, bug fixes, and ecosystem expansion. | ||
### Automatic Dependency Collection \{#automatic-dependency-collection} | ||
|
||
Migrating more hooks to use the **Automatic Dependency Collection** scheme. This is transparent to users but can significantly reduce unnecessary renders. For details, see [Dependency Collection](/docs/features/dependencies-collection). | ||
|
||
## v2 Version \{#v2-version} | ||
|
||
Improvements and optimizations will be made to address the issues and shortcomings of the current v1 version, which will introduce breaking changes: | ||
|
||
### Adjust `useSupported` \{#adjust-use-supported} | ||
|
||
Adjust the API return to expose the `isSupported` attribute as an object, enabling the Automatic Dependency Collection scheme. At the same time, force the user to explicitly specify a fallback function for "when the browser does not support the feature," aiming to explicitly remind developers to handle potential compatibility problems and reduce the likelihood of misuse. | ||
|
||
> All internal hooks that depend on `useSupported` will be adjusted to fit the new API return format. | ||
```tsx | ||
// === Before Changing (v1) === | ||
const isSupported = useSupported(() => 'IntersectionObserver' in window) | ||
console.log(isSupported) // true | ||
|
||
// === After Changing (v2) === | ||
const { isSupported } = useSupported(() => 'IntersectionObserver' in window, { | ||
// onUnsupported must be explicitly specified | ||
onUnsupported: () => { | ||
console.log('IntersectionObserver is unsupported.') | ||
} | ||
}) | ||
console.log(isSupported) // true | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,34 @@ | ||
# 后期规划(Roadmap) | ||
|
||
## v1 版本(当前版本) \{#v1-version} | ||
|
||
> 功能已基本完善,后期主要针对现有 Hooks 进行功能迭代、问题修复和生态扩充。 | ||
## V1(当前版本) | ||
### 自动依赖收集 \{#automatic-dependency-collection} | ||
|
||
迁移更多 Hooks 以使用**自动依赖收集**方案。对用户使用无感,但能显著降低不必要的渲染,详情参考 [依赖收集](/docs/features/dependencies-collection)。 | ||
|
||
## v2 版本 \{#v2-version} | ||
|
||
针对当前 v1 版本的问题和不足进行改进优化,会引入破坏性变更: | ||
|
||
### 调整 `useSupported` \{#adjustments-to-use-supported} | ||
|
||
调整 API 返回,以对象的形式暴露 `isSupported` 属性,以启用自动依赖收集方案。同时,在 API 层面强制用户显式指定「当浏览器不支持该特性时的」回退处理函数,这一更改旨在显式提醒开发者处理可能存在的兼容性问题,以降低错误使用的可能性。 | ||
|
||
> 将会对所有内部依赖 `useSupported` 的 Hooks 进行调整,以适配新的 API 返回形式。 | ||
```tsx | ||
// === 更改前 (v1) === | ||
const isSupported = useSupported(() => 'IntersectionObserver' in window) | ||
console.log(isSupported) // true | ||
|
||
// === 更改后 (v2) === | ||
const { isSupported } = useSupported(() => 'IntersectionObserver' in window, { | ||
// onUnsupported 必须显式指定 | ||
onUnsupported: () => { | ||
console.log('IntersectionObserver is unsupported.') | ||
} | ||
}) | ||
console.log(isSupported) // true | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters