You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[core] Add optional initial value arguments to useNetworkStatus, useSaveData; useMemoryStatus (#23)
* Update useNetworkStatus to accept initialEffectiveConnectionType arg and consistently return unsupported property; add tests
* Update useHardwareConcurrency to consistently return unsupported property; add tests
* Update useMemoryStatus to accept initialMemoryStatus arg and consistently return unsupported property; add tests
* Update useSaveData to accept initialSaveDataStatus; add tests
* Update package.json with test coverage script
* Update readme with documentation for new hook arguments and use cases
* Update readme and network spec to address CR comments
Copy file name to clipboardExpand all lines: README.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,14 @@ const MyComponent = () => {
68
68
};
69
69
```
70
70
71
+
This hook accepts an optional `initialEffectiveConnectionType` string argument, which can be used to provide a `effectiveConnectionType` state value when the user's browser does not support the relevant [NetworkInformation API](https://wicg.github.io/netinfo/). Passing an initial value can also prove useful for server-side rendering, where the developer can pass an [ECT Client Hint](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/client-hints#ect) to detect the effective network connection type.
`useSaveData` utility for adapting based on the user's browser Data Saver preferences.
@@ -87,6 +95,14 @@ const MyComponent = () => {
87
95
};
88
96
```
89
97
98
+
This hook accepts an optional `initialSaveDataStatus` boolean argument, which can be used to provide a `saveData` state value when the user's browser does not support the relevant [NetworkInformation API](https://wicg.github.io/netinfo/). Passing an initial value can also prove useful for server-side rendering, where the developer can pass a server [Save-Data Client Hint](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/client-hints#save-data) that has been converted to a boolean to detect the user's data saving preference.
`useHardwareConcurrency` utility for adapting to the number of logical CPU processor cores on the user's device.
@@ -125,6 +141,14 @@ const MyComponent = () => {
125
141
};
126
142
```
127
143
144
+
This hook accepts an optional `initialMemoryStatus` object argument, which can be used to provide a `deviceMemory` state value when the user's browser does not support the relevant [DeviceMemory API](https://github.com/w3c/device-memory). Passing an initial value can also prove useful for server-side rendering, where the developer can pass a server [Device-Memory Client Hint](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/client-hints#save-data) to detect the memory capacity of the user's device.
0 commit comments