|
1 |
| -## 7.0.0-wip |
| 1 | +## 7.0.0 |
2 | 2 |
|
3 | 3 | - Migrate to null safety
|
4 |
| - |
5 |
| -#### Deprecated API removals |
6 |
| -- forwardRef (use forwardRef2 instead) |
7 |
| -- memo (use memo2 instead) |
8 |
| -- main (use htmlMain instead) |
9 |
| -- Ref class constructors: default and `useRefInit` (use useRef/createRef instead) |
10 |
| -- ReducerHook and StateHook class constructors (use hook functions instead). |
| 4 | +- Remove deprecated APIs (see below) |
| 5 | +- Minor API breakages to support null safety migration and improve typing (see below) |
| 6 | + |
| 7 | +## Deprecated API removals |
| 8 | +- `ReducerHook` and `StateHook` class constructors (use hook functions instead) |
| 9 | +- `Ref` class constructors: default and `useRefInit` (use `createRef` and `useRef` instead) |
| 10 | +- `forwardRef` (use `forwardRef2` instead) |
| 11 | +- `main` (use `htmlMain` instead) |
| 12 | +- `memo` (use `memo2` instead) |
11 | 13 | - APIs that have been no-ops since react-dart 6.0.0
|
12 |
| - - SyntheticEvent members `persist` and `isPersistent` |
13 |
| - - unconvertJsEventHandler |
| 14 | + - `SyntheticEvent` members `persist` and `isPersistent` |
| 15 | + - `unconvertJsEventHandler` |
14 | 16 | - APIs that were never intended for public use:
|
15 |
| - - JsPropValidator |
16 |
| - - dartInteropStatics |
17 |
| - - ComponentStatics(2) |
18 |
| - - createReactDartComponentClass(2) |
19 |
| - - JsComponentConfig(2) |
20 |
| - - ReactDartInteropStatics |
21 |
| - - InteropContextValue |
22 |
| - - markChildrenValidated |
23 |
| - |
24 |
| -#### Other API breakages |
25 |
| -- ReducerHook and StateHook have no public constructors and can no longer be extended |
26 |
| -- Ref.fromJs is now a factory constructor, meaning the Ref class can no longer be extended |
27 |
| -- ReactComponentFactoryProxy.call and .build return type changed from dynamic to ReactElement |
28 |
| - - This matches the type returned from `build` for all subclasses, which is what’s returned by call, and reflects the type returned at runtime |
29 |
| - - Has potential to cause some static analysis issues, but for the most part should not affect anything since ReactElement is typically treated as an opaque type |
30 |
| - - Needs consumer tests |
31 |
| - - Top-level component factories are typed as ReactDomComponentFactoryProxy instead of being `dynamic`: react.div |
32 |
| -- All PropValidatorInfo arguments are required |
33 |
| -- Changes to public but internal code that should not affect consumers: |
34 |
| - - ReactDartComponentInternal |
35 |
| - - Constructor now takes a required argument, props is final |
36 |
| - - initComponentInternal arguments are typed to reflect runtime assumptions |
37 |
| -- ReactComponentFactoryProxy no longer `implements Function` |
38 |
| - - This should not be a breakage, since as of Dart 2.0 inheriting from Function has had no effect |
39 |
| - |
40 |
| -#### Potential behavior breakages |
41 |
| -- Component and Component2 members `props`/`state`/`jsThis` are late, will now throw instead of being null if accessed before initialized (e.g., in a constructor, final class field, or static lifecycle method). |
| 17 | + - `ComponentStatics`, `ComponentStatics2` |
| 18 | + - `InteropContextValue` |
| 19 | + - `JsComponentConfig`, `JsComponentConfig2` |
| 20 | + - `JsError` |
| 21 | + - `JsPropValidator` |
| 22 | + - `React.createFactory` |
| 23 | + - `ReactDartContextInternal` |
| 24 | + - `ReactDartInteropStatics` |
| 25 | + - `ReactElementStore` |
| 26 | + - `createReactDartComponentClass`, `createReactDartComponentClass2` |
| 27 | + - `markChildValidated` |
| 28 | + - `markChildrenValidated` |
| 29 | + |
| 30 | +### Other API breakages |
| 31 | + |
| 32 | +#### Miscellaneous: |
| 33 | +- `ReducerHook`, `StateHook`, and `Ref` are now `@sealed` and may not be inherited from |
| 34 | +- All `PropValidatorInfo` arguments are required |
| 35 | + |
| 36 | +#### Typing improvements: |
| 37 | + - Top-level DOM factories exported from `package:react/react.dart` (`react.div`, `react.span`, etc.) are now typed as `ReactDomComponentFactoryProxy` instead of `dynamic` |
| 38 | + - The return types of `ReactComponentFactoryProxy` methods `call` and `build` are now `ReactElement` instead of `dynamic` |
| 39 | + - This matches the type returned from `build` for all subclasses, which is what’s returned by call, and reflects the type returned at runtime |
| 40 | + - Has potential to cause some static analysis issues, but for the most part should not affect anything since `ReactElement` is typically treated as an opaque type |
| 41 | + |
| 42 | +#### Changes very unlikely to affect consumers: |
| 43 | +- Changes to public-but-internal APIs: |
| 44 | + - `ReactDartComponentInternal` constructor now takes a required argument, `props` field is `final` |
| 45 | + - `initComponentInternal` arguments are typed to reflect runtime assumptions |
| 46 | +- `Component` and `Component2` members `props`/`state`/`jsThis` are now [late](https://dart.dev/language/variables#late-variables), and will now throw instead of being null if accessed before initialized. |
| 47 | + |
| 48 | + It should be very uncommon for components to be affected by this change, and any affected components are likely doing something wrong to begin with. |
| 49 | + |
| 50 | + These fields are only uninitialized: |
| 51 | + - for mounting component instances: |
| 52 | + - in component class constructors (which we don't encourage) |
| 53 | + - in component class field initializers (except for lazy `late` ones) |
| 54 | + - in "static" lifecycle methods like `getDerivedStateFromProps` and `defaultProps` |
| 55 | + |
| 56 | + Examples of code affected: |
| 57 | + ```dart |
| 58 | + class FooComponent extends Component2 { |
| 59 | + // `props` would have always been null when this is initialized, but in 7.0.0 accessing it throws. |
| 60 | + final something = (props ?? {})['something']; |
| 61 | +
|
| 62 | + // We strongly discourage declaring Dart constructors in component classes; |
| 63 | + // for initialization logic, use componentDidMount instead. |
| 64 | + FooComponent() { |
| 65 | + // `props` would have always been null here, but in 7.0.0 accessing it throws. |
| 66 | + print(props); |
| 67 | + } |
| 68 | +
|
| 69 | + @override |
| 70 | + getDerivedStateFromProps(nextProps, prevState) { |
| 71 | + // `props` would have always been null here, but in 7.0.0 accessing it throws. |
| 72 | + print(props); |
| 73 | + return {}; |
| 74 | + } |
| 75 | + } |
| 76 | + ``` |
| 77 | +
|
42 | 78 |
|
43 | 79 | ## [6.3.0](https://github.com/Workiva/react-dart/compare/6.2.1...6.3.0)
|
44 | 80 | - [#372], [#374] Add and update deprecations in preparation for 7.0.0 release, add WIP changelog
|
|
0 commit comments