Skip to content

Commit 45aeae4

Browse files
Deprecate constructors
1 parent fababf7 commit 45aeae4

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/hooks.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class StateHook<T> {
2323
/// The second item in the pair returned by [React.useState].
2424
void Function(dynamic) _setValue;
2525

26+
@Deprecated('Use useState instead. Will be removed in 7.0.0.')
2627
StateHook(T initialValue) {
2728
final result = React.useState(initialValue);
2829
_value = result[0] as T;
@@ -33,6 +34,7 @@ class StateHook<T> {
3334
/// initialize [_value] to the return value of [init].
3435
///
3536
/// See: <https://reactjs.org/docs/hooks-reference.html#lazy-initial-state>.
37+
@Deprecated('Use useStateLazy instead. Will be removed in 7.0.0.')
3638
StateHook.lazy(T Function() init) {
3739
final result = React.useState(allowInterop(init));
3840
_value = result[0] as T;
@@ -171,6 +173,7 @@ class ReducerHook<TState, TAction, TInit> {
171173
/// The second item in the pair returned by [React.useReducer].
172174
void Function(TAction) _dispatch;
173175

176+
@Deprecated('Use useReducer instead. Will be removed in 7.0.0.')
174177
ReducerHook(TState Function(TState state, TAction action) reducer, TState initialState) {
175178
final result = React.useReducer(allowInterop(reducer), initialState);
176179
_state = result[0] as TState;
@@ -181,6 +184,7 @@ class ReducerHook<TState, TAction, TInit> {
181184
/// initialize [_state] to the return value of [init(initialArg)].
182185
///
183186
/// See: <https://reactjs.org/docs/hooks-reference.html#lazy-initialization>.
187+
@Deprecated('Use useReducerLazy instead. Will be removed in 7.0.0.')
184188
ReducerHook.lazy(
185189
TState Function(TState state, TAction action) reducer, TInit initialArg, TState Function(TInit) init) {
186190
final result = React.useReducer(allowInterop(reducer), initialArg, allowInterop(init));

lib/react_client/react_interop.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ class Ref<T> {
9898
/// A JavaScript ref object returned by [React.createRef].
9999
final JsRef jsRef;
100100

101+
@Deprecated('Use createRef instead. Will be removed in 7.0.0.')
101102
Ref() : jsRef = React.createRef();
102103

103104
/// Constructor for [useRef], calls [React.useRef] to initialize [current] to [initialValue].
104105
///
105106
/// See: <https://reactjs.org/docs/hooks-reference.html#useref>.
107+
@Deprecated('Use useRef or useRefInit instead. Will be removed in 7.0.0.')
106108
Ref.useRefInit(T initialValue) : jsRef = React.useRef(initialValue);
107109

108110
Ref.fromJs(this.jsRef);
@@ -650,6 +652,9 @@ class InteropProps implements JsMap {
650652
/// > __For internal/advanced use only.__
651653
@Deprecated('Only used with the deprecated Component base class and not Component2.')
652654
class ReactDartComponentInternal {
655+
@Deprecated('For internal use only. Will have a required argument in 7.0.0.')
656+
ReactDartComponentInternal();
657+
653658
/// For a `ReactElement`, this is the initial props with defaults merged.
654659
///
655660
/// For a `ReactComponent`, this is the props the component was last rendered with,

0 commit comments

Comments
 (0)