Skip to content

Commit

Permalink
Merge pull request #909 from Workiva/FED-2136_deprecate_args
Browse files Browse the repository at this point in the history
FED-2136 Deprecate optional value argument in useRef hook & createContext fn
  • Loading branch information
rmconsole3-wf authored Apr 5, 2024
2 parents 7b8c641 + 81f3e3b commit fa553bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
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

0 comments on commit fa553bb

Please sign in to comment.