Skip to content

Commit

Permalink
Update existing deprecations, notably outdated Component removal time…
Browse files Browse the repository at this point in the history
…line
  • Loading branch information
greglittlefield-wf committed Sep 26, 2023
1 parent e439306 commit a6c58c0
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 171 deletions.
229 changes: 114 additions & 115 deletions lib/react.dart

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions lib/react_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ export 'package:react/src/typedefs.dart' show JsFunctionComponent;
/// > __DEPRECATED.__
/// >
/// > Environment configuration is now done by default and should not be altered. This can now be removed.
/// > This will be removed in 7.0.0, along with other configuration setting functions.
@Deprecated('It is not longer required and can be removed. Will be removed from this library in the 7.0.0 release.')
@Deprecated('Calls to this function are no longer required and can be removed.')
void setClientConfiguration() {}
6 changes: 2 additions & 4 deletions lib/react_client/component_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ mixin JsBackedMapComponentFactoryMixin on ReactComponentFactoryProxy {
static JsMap generateExtendedJsProps(Map props) => generateJsProps(props, wrapWithJsify: false);
}

/// Use [ReactDartComponentFactoryProxy2] instead by calling [registerComponent2].
///
/// Will be removed when [Component] is removed in the `7.0.0` release.
@Deprecated('7.0.0')
@Deprecated('Only used with the deprecated Component base class and not Component2,'
' which uses ReactDartComponentFactoryProxy2. Will be removed along with Component.')
class ReactDartComponentFactoryProxy<TComponent extends Component> extends ReactComponentFactoryProxy {
/// The ReactJS class used as the type for all [ReactElement]s built by
/// this factory.
Expand Down
67 changes: 23 additions & 44 deletions lib/react_client/react_interop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ abstract class React {
dynamic defaultValue,
int Function(dynamic currentValue, dynamic nextValue) calculateChangedBits,
]);
@Deprecated('7.0.0')
@Deprecated('For internal use only.')
external static ReactClass createClass(ReactClassConfig reactClassConfig);
@Deprecated('7.0.0')
@Deprecated('Use createElement instead. To be removed in 7.0.0.')
external static ReactJsComponentFactory createFactory(type);
external static ReactElement createElement(dynamic type, props, [dynamic children]);
external static JsRef createRef();
Expand Down Expand Up @@ -397,9 +397,9 @@ class ReactClass {
///
/// For use in `ReactDartComponentFactoryProxy` when creating new [ReactElement]s,
/// or for external use involving inspection of Dart prop defaults.
@Deprecated('7.0.0`')
@Deprecated('Only used with the deprecated Component base class and not Component2.')
external Map get dartDefaultProps;
@Deprecated('7.0.0`')
@Deprecated('Only used with the deprecated Component base class and not Component2.')
external set dartDefaultProps(Map value);

/// A string to distinguish between different Dart component implementations / base classes.
Expand Down Expand Up @@ -451,8 +451,8 @@ abstract class ReactDartComponentVersion {
///
/// > __DEPRECATED.__
/// >
/// > Will be removed alongside [React.createClass] in the `7.0.0` release.
@Deprecated('7.0.0')
/// > Will be removed alongside [React.createClass].
@Deprecated('For internal use only.')
@JS()
@anonymous
class ReactClassConfig {
Expand Down Expand Up @@ -559,7 +559,6 @@ class ReactPortal {
@JS()
@anonymous
class ReactComponent {
// TODO: Cast as Component2 in 7.0.0
external Component get dartComponent;
// TODO how to make this JsMap without breaking stuff?
external InteropProps get props;
Expand All @@ -585,10 +584,10 @@ class ReactComponent {
/// > __DEPRECATED - DO NOT USE__
/// >
/// > This API was never stable in any version of ReactJS, and was replaced with a new, incompatible context API
/// > in ReactJS 16 that is exposed via the [Component2] class.
/// > in ReactJS 16.
/// >
/// > This will be completely removed when the JS side of it is slated for removal (ReactJS 18 / react.dart 7.0.0)
@Deprecated('7.0.0')
/// > This will be completely removed alongside the Component class.
@Deprecated('For internal use only. Will be made private in 7.0.0.')
@JS()
@anonymous
class InteropContextValue {
Expand Down Expand Up @@ -617,29 +616,18 @@ class ReactContext {
@JS()
@anonymous
class InteropProps implements JsMap {
/// __Deprecated.__
///
/// This has been deprecated along with `Component` since its
/// replacement - `Component2` utilizes JS Maps for props,
/// making `internal` obsolete.
///
/// Will be removed alongside `Component` in the `7.0.0` release.
@Deprecated('7.0.0')
/// The Dart props for components using [Component], but not [Component2],
/// which stores props as properties on this object.
@Deprecated('Only used with the deprecated Component base class and not Component2,'
' which stores props as properties on this object.')
external ReactDartComponentInternal get internal;
external dynamic get key;
external dynamic get ref;

external set key(dynamic value);
external set ref(dynamic value);

/// __Deprecated.__
///
/// This has been deprecated along with `Component` since its
/// replacement - `Component2` utilizes JS Maps for props,
/// making `InteropProps` obsolete.
///
/// Will be removed alongside `Component` in the `7.0.0` release.
@Deprecated('7.0.0')
@Deprecated('For internal use only. Only used with the deprecated Component base class and not Component2.')
external factory InteropProps({
ReactDartComponentInternal internal,
String key,
Expand All @@ -653,13 +641,13 @@ class InteropProps implements JsMap {
/// replacement - `Component2` utilizes JS Maps for props,
/// making `InteropProps` obsolete.
///
/// Will be removed alongside `Component` in the `7.0.0` release.
/// Will be removed alongside `Component` in a future major release.
///
/// > Internal react-dart information used to proxy React JS lifecycle to Dart
/// > [Component] instances.
/// >
/// > __For internal/advanced use only.__
@Deprecated('7.0.0')
@Deprecated('Only used with the deprecated Component base class and not Component2.')
class ReactDartComponentInternal {
/// For a `ReactElement`, this is the initial props with defaults merged.
///
Expand All @@ -676,10 +664,10 @@ class ReactDartComponentInternal {
/// > __DEPRECATED - DO NOT USE__
/// >
/// > This API was never stable in any version of ReactJS, and was replaced with a new, incompatible context API
/// > in ReactJS 16 that is exposed via the [Component2] class.
/// > in ReactJS 16.
/// >
/// > This will be completely removed when the JS side of it is slated for removal (ReactJS 18 / react.dart 7.0.0)
@Deprecated('7.0.0')
/// > This will be completely removed alongside the Component class.
@Deprecated('For internal use only. Will be made private in 7.0.0.')
class ReactDartContextInternal {
final dynamic value;

Expand Down Expand Up @@ -730,12 +718,8 @@ void markChildrenValidated(List<dynamic> children) {
/// Returns a new JS [ReactClass] for a component that uses
/// [dartInteropStatics] and [componentStatics] internally to proxy between
/// the JS and Dart component instances.
///
/// > __DEPRECATED.__
/// >
/// > Will be removed in `7.0.0` alongside [Component].
@JS('_createReactDartComponentClass')
@Deprecated('7.0.0')
@Deprecated('For internal use only. Will be made private in 7.0.0.')
external ReactClass createReactDartComponentClass(
ReactDartInteropStatics dartInteropStatics, ComponentStatics componentStatics,
[JsComponentConfig jsConfig]);
Expand Down Expand Up @@ -765,13 +749,9 @@ external bool get _inReactDevMode;
bool get inReactDevMode => _inReactDevMode;

/// An object that stores static methods used by all Dart components.
///
/// __Deprecated.__
///
/// Will be removed when [Component] is removed in the `7.0.0` release.
@JS()
@anonymous
@Deprecated('7.0.0')
@Deprecated('For internal use only. Will be made private in 7.0.0.')
class ReactDartInteropStatics {
external factory ReactDartInteropStatics({
Component Function(
Expand Down Expand Up @@ -836,9 +816,8 @@ class ComponentStatics2 {
/// > and was replaced with a new, incompatible context API in ReactJS 16 that is exposed
/// > via the [Component2] class and is supported by [JsComponentConfig2].
/// >
/// > This will be completely removed when the JS side of `context` it is slated for
/// > removal (ReactJS 18 / react.dart 7.0.0)
@Deprecated('7.0.0')
/// > This will be completely removed alongside the Component class.
@Deprecated('For internal use only. Will be made private in 7.0.0.')
@JS()
@anonymous
class JsComponentConfig {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/react_client/component_registration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ List<String> _filterSkipMethods(Iterable<String> methods) {

/// Creates and returns a new [ReactDartComponentFactoryProxy] from the provided [componentFactory]
/// which produces a new JS `ReactClass` component class.
@Deprecated('7.0.0')
@Deprecated('Migrate to Component2 and use registerComponent2 instead.')
ReactDartComponentFactoryProxy registerComponent(
ComponentFactory componentFactory, [
Iterable<String> skipMethods = const ['getDerivedStateFromError', 'componentDidCatch'],
Expand Down
2 changes: 1 addition & 1 deletion lib/src/react_client/dart_interop_statics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'package:react/src/react_client/private_utils.dart';
import 'package:react/src/typedefs.dart';

/// The static methods that proxy JS component lifecycle methods to Dart components.
@Deprecated('7.0.0')
@Deprecated('For internal use only. Will be made private in 7.0.0.')
final ReactDartInteropStatics dartInteropStatics = (() {
final zone = Zone.current;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/react_client/event_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ extension SyntheticEventTypeHelpers on SyntheticEvent {
/// Whether the event instance has been removed from the ReactJS event pool.
///
/// > See: [persist]
@Deprecated('The modern event system does not use pooling. This always returns true, and will be removed in 7.0.0.')
@Deprecated('The modern event system does not use pooling. This always returns true, and will be removed.')
bool get isPersistent => true;

/// Uses Duck Typing to detect if the event instance is a [SyntheticClipboardEvent].
Expand Down
2 changes: 1 addition & 1 deletion lib/src/react_client/factory_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dynamic convertArgsToChildren(List childrenArgs) {
}
}

@Deprecated('Event handlers are no longer converted. This will be removed in 7.0.0.')
@Deprecated('This is no longer necessary since event handlers are no longer converted.')
Function unconvertJsEventHandler(Function jsConvertedEventHandler) => null;

void convertRefValue(Map args) {
Expand Down
6 changes: 4 additions & 2 deletions lib/src/react_client/private_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import 'package:react/src/js_interop_util.dart';
/// This is used when setting environment variables to ensure they can be set properly.
bool _isJsApiValid = false;

@Deprecated('7.0.0')
@Deprecated(
'This is only used with the legacy context APIs in the deprecated Component, and will be removed along with them.')
InteropContextValue jsifyContext(Map<String, dynamic> context) {
final interopContext = InteropContextValue();
context.forEach((key, value) {
Expand All @@ -29,7 +30,8 @@ T validateJsApiThenReturn<T>(T Function() computeReturn) {
return computeReturn();
}

@Deprecated('7.0.0')
@Deprecated(
'This is only used with the legacy context APIs in the deprecated Component, and will be removed along with them.')
Map<String, dynamic> unjsifyContext(InteropContextValue interopContext) {
// TODO consider using `contextKeys` for this if perf of objectKeys is bad.
return Map.fromIterable(objectKeys(interopContext), value: (key) {
Expand Down

0 comments on commit a6c58c0

Please sign in to comment.