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

FED-2136 Deprecate optional value argument in useRef hook & createContext fn #909

Merged
merged 2 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# OverReact Changelog

## 5.1.0
- [#909] Deprecate the optional `initialValue` argument in the `useRef` hook.
- Use the `useRefInit` hook instead if you need to set an initial value.
- [#909] Deprecate the optional `defaultValue` argument in `createContext`.
- Use `createContextInit` instead if you need to set a default value.

## 5.0.1
- Consume over_react_test 3.0.0

Expand Down
7 changes: 3 additions & 4 deletions lib/src/component/hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,9 @@ T useContext<T>(Context<T> context) => react_hooks.useContext(context.reactDartC
///
/// Learn more: <https://reactjs.org/docs/hooks-reference.html#useref>.
Ref<T?> useRef<T>([
// TODO(FED-2136) uncomment this deprecation
// @Deprecated('Use `useRefInit` instead to create refs with initial values.'
// ' Since the argument to useRefInit is required, it can be used to create a Ref that holds a non-nullable type,'
// ' whereas this function can only create Refs with nullable type arguments.')
@Deprecated('Use `useRefInit` instead to create refs with initial values.'
' Since the argument to useRefInit is required, it can be used to create a Ref that holds a non-nullable type,'
' whereas this function can only create Refs with nullable type arguments.')
T? initialValue,
]) =>
// ignore: deprecated_member_use
Expand Down
7 changes: 3 additions & 4 deletions lib/src/util/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,9 @@ class _DO_NOT_USE_OR_YOU_WILL_BE_FIRED {
///
/// Learn more: <https://react.dev/reference/react/createContext>
Context<TValue?> createContext<TValue>([
// TODO(FED-2136) uncomment this deprecation
// @Deprecated('Use `createContextInit` instead to create contexts with initial values.'
// ' Since the argument to createContextInit is required, it can be used to create a context that holds a non-nullable type,'
// ' whereas this function can only create contexts with nullable type arguments.')
@Deprecated('Use `createContextInit` instead to create contexts with initial values.'
' Since the argument to createContextInit is required, it can be used to create a context that holds a non-nullable type,'
' whereas this function can only create contexts with nullable type arguments.')
TValue? defaultValue,
int Function(TValue?, TValue?)? calculateChangedBits,
]) => createContextInit(defaultValue, calculateChangedBits);
Expand Down
Loading