Skip to content

RM-93030 Release react-dart 6.0.0 #285

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

Merged
merged 91 commits into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
952afbe
upgrade to react 17rc
kealjones-wk Aug 11, 2020
b44f3da
Bump to 17.0.0-rc.1
joebingham-wk Sep 4, 2020
92a1aa0
Bump react DOM
joebingham-wk Sep 8, 2020
a6c1e0d
fix PropTypes react 17
kealjones-wk Sep 10, 2020
647dfa9
Merge branch 'master' into testing-react-17-rc
kealjones-wk Sep 10, 2020
d4f429d
Bump to 17.0.0-rc.3
sydneyjodon-wk Oct 15, 2020
aac076c
Build
sydneyjodon-wk Oct 15, 2020
af09134
Merge branch 'master' into testing-react-17-rc
sydneyjodon-wk Oct 15, 2020
e03966a
Re-build after merge
sydneyjodon-wk Oct 15, 2020
def6f61
Update display name implementation
sydneyjodon-wk Oct 21, 2020
8aa7feb
Bump to released react 17.0.0
sydneyjodon-wk Oct 21, 2020
1ef1196
Remove deprecated APIs
sydneyjodon-wk Oct 21, 2020
3ae0140
Add compile-time check
sydneyjodon-wk Oct 22, 2020
2978197
Update test
sydneyjodon-wk Oct 23, 2020
f20d343
Merge pull request #277 from cleandart/testing-react-17-rc
greglittlefield-wf Nov 4, 2020
265791f
Merge branch 'master' of github.com:cleandart/react-dart into 6.0.0-wip
joebingham-wk Nov 9, 2020
4bf7a6a
Merge cherry-pick
greglittlefield-wf Sep 11, 2020
3f7c662
Remove anonymous annotations from event wrappers
sydneyjodon-wk Oct 27, 2020
8d35e58
Merge in cherry-pick
sydneyjodon-wk Nov 2, 2020
bc328de
Merge branch 'master' of github.com:cleandart/react-dart into 6.0.0-wip
joebingham-wk Nov 9, 2020
e0bbf95
Merge branch '6.0.0-wip' of github.com:cleandart/react-dart into CPLA…
joebingham-wk Nov 9, 2020
887077a
Add new event creators
joebingham-wk Nov 9, 2020
90bf4b7
Add some type checking utils
joebingham-wk Nov 9, 2020
25fdee7
Finish adding doc comments
joebingham-wk Nov 10, 2020
132ef6a
Remove default constructors
joebingham-wk Nov 10, 2020
502c6ca
More strongly type dataTransfer
joebingham-wk Nov 10, 2020
65a7ad5
Adjust test
joebingham-wk Nov 10, 2020
e4ee896
Format
joebingham-wk Nov 10, 2020
d5af6de
Clean up
joebingham-wk Nov 10, 2020
3b672a7
Use 'hasProperty'
joebingham-wk Nov 11, 2020
a3aaa07
Add doc comments
joebingham-wk Nov 16, 2020
7699f8f
Add deprecations
joebingham-wk Nov 16, 2020
59b702c
Add back SyntheticDataTransfer
joebingham-wk Nov 16, 2020
a1436c7
Add a comment for SyntheticFormEvent
joebingham-wk Nov 16, 2020
54af213
Add tests for data transfer helper
joebingham-wk Nov 16, 2020
fff5582
Change helper method name
joebingham-wk Nov 16, 2020
8063199
Remove unnecessary import
joebingham-wk Nov 16, 2020
c149188
Address misc feedback
joebingham-wk Nov 18, 2020
067e282
Remove isFormEvent
joebingham-wk Nov 18, 2020
2bc5ffa
Update doc comments
joebingham-wk Nov 18, 2020
215d9ec
Tweak a couple more comments
joebingham-wk Nov 18, 2020
dc72ba9
Make isPersistent an extension
joebingham-wk Nov 18, 2020
85ddcfc
Rename helper extension
joebingham-wk Nov 18, 2020
9aa536f
Undo renaming
joebingham-wk Nov 18, 2020
7d1bc70
Clean up cast
joebingham-wk Nov 18, 2020
052c5b6
Merge pull request #284 from cleandart/CPLAT-12470-remove-synthetic-e…
greglittlefield-wf Nov 18, 2020
05c67a9
Merge in master
joebingham-wk Nov 24, 2020
14811ab
Test type checks on simulated events
sydneyjodon-wk Nov 24, 2020
ed5f0a0
Merge branch '6.0.0-wip' into update-event-duck-typing
sydneyjodon-wk Nov 24, 2020
25770b5
Update duck typing to check type property
sydneyjodon-wk Nov 24, 2020
3fc33d8
Remove typing changes
joebingham-wk Nov 25, 2020
5d7888e
Remove print statement
sydneyjodon-wk Nov 25, 2020
41e8563
Remove form event type checking
sydneyjodon-wk Nov 25, 2020
43b6829
Bump react.js to 17.0.1
joebingham-wk Nov 25, 2020
3715d3c
Merge branch '6.0.0-wip' into update-event-duck-typing
sydneyjodon-wk Nov 25, 2020
6635823
Merge branch 'master' of github.com:cleandart/react-dart into 6.0.0-wip
joebingham-wk Nov 25, 2020
1f475cb
Address feedback
sydneyjodon-wk Nov 25, 2020
03454a1
Update type equality checks
sydneyjodon-wk Nov 25, 2020
308d88e
Merge branch 'master' of github.com:cleandart/react-dart into 6.0.0-wip
joebingham-wk Nov 30, 2020
34bb913
Merge pull request #288 from cleandart/update-event-duck-typing
sydneyjodon-wk Nov 30, 2020
3c7a0a6
Update changelog
joebingham-wk Nov 30, 2020
34386c3
Merge branch '6.0.0-wip' of github.com:cleandart/react-dart into 6.0.…
joebingham-wk Nov 30, 2020
14735aa
Point changelog to PR
joebingham-wk Nov 30, 2020
c43d491
Move prop validation to getDerivedStateFromProps
sydneyjodon-wk Dec 1, 2020
45e73bf
Merge branch '6.0.0-wip' into test-proptypes-in-getDerivedStateFromProps
sydneyjodon-wk Dec 1, 2020
bffba0e
Address misc feedback
joebingham-wk Dec 1, 2020
b677f6d
Switch to using yarn
joebingham-wk Dec 1, 2020
ee916dc
Remove unused import
joebingham-wk Dec 1, 2020
4750550
Bump react dependencies
joebingham-wk Dec 1, 2020
1341bb2
Add missing period
joebingham-wk Dec 1, 2020
21731f8
Merge branch '6.0.0-wip' into test-proptypes-in-getDerivedStateFromProps
sydneyjodon-wk Dec 1, 2020
672111d
Resolve merge conflicts
sydneyjodon-wk Dec 1, 2020
dae1510
Merge pull request #292 from cleandart/test-proptypes-in-getDerivedSt…
joebingham-wk Dec 2, 2020
962a8b1
Add TODOs and link to issue for SyntheticEvent classes
greglittlefield-wf Dec 17, 2020
18b8207
Wrap console.warn in dev builds to silence excessive SyntheticEvent t…
greglittlefield-wf Dec 17, 2020
e2fe5a4
Compile JS assets
greglittlefield-wf Dec 17, 2020
1692efb
Update name of tests for shared builds
greglittlefield-wf Dec 17, 2020
cabce84
Fix comment typo
greglittlefield-wf Dec 17, 2020
250f2fc
Merge pull request #293 from cleandart/synthetic-event-warnings
greglittlefield-wf Dec 17, 2020
1fede84
Return false from “is” synthetic event checks when event is null
aaronlademann-wf Dec 18, 2020
84bb6a8
Merge pull request #294 from cleandart/improve-synthetic-event-null-h…
greglittlefield-wf Dec 18, 2020
471e879
Bump version to 6.0.0
joebingham-wk Jan 12, 2021
a70f625
Add link to React 17 Release blog post
joebingham-wk Jan 12, 2021
8a58f8e
Regenerate JS bundles
greglittlefield-wf Jan 12, 2021
cbb3f21
Add aviary.yaml to exclude some files
greglittlefield-wf Jan 13, 2021
3043ca2
npm audit fix
greglittlefield-wf Jan 13, 2021
fa7bfd4
Update README
aaronlademann-wf Jan 14, 2021
75875ec
Merge branch 'master' of github.com:workiva/react-dart into 6.0.0-wip
aaronlademann-wf Jan 14, 2021
01aff35
Resolve peerDependencies warning for react-redux
aaronlademann-wf Jan 14, 2021
7247759
Merge pull request #299 from Workiva/6.0.0_peerDependencies-fix
greglittlefield-wf Jan 14, 2021
d4a9e9c
Merge branch 'master' into 6.0.0-wip
greglittlefield-wf Jan 14, 2021
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## [6.0.0](https://github.com/cleandart/react-dart/compare/5.7.1...6.0.0)

This stable, __major__ release of react includes:

### ReactJS 17.x Support

The underlying `.js` files provided by this package are now ReactJS version `17.0.1`.

> __[Full List of Breaking Changes](https://github.com/cleandart/react-dart/pull/285)__

> __[React 17 Release Blog Post](https://reactjs.org/blog/2020/10/20/react-v17.html)__

## [5.7.1](https://github.com/cleandart/react-dart/compare/5.7.0...5.7.1)

- [#289] Update most deprecations that were slated for removal in v6.0.0 to be slated for removal in v7.0.0 instead. To keep the migration to v6.0.0 as easy as possible, only APIs that are known to be completely unused will be removed in v6.0.0. Therefore, most APIs that were marked for removal in v6.0.0 will remain until the v7.0.0 release. This PR updated deprecation annotations to reflect this.
Expand Down
79 changes: 27 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Dart wrapper for [React JS](https://reactjs.org/)

[![Pub](https://img.shields.io/pub/v/react.svg)](https://pub.dev/packages/react)
![ReactJS v16.10.1](https://img.shields.io/badge/React_JS-v16.10.1-green.svg)
![ReactJS v17.0.1](https://img.shields.io/badge/React_JS-v17.0.1-green.svg)
[![Dart CI](https://github.com/Workiva/react-dart/workflows/Dart%20CI/badge.svg?branch=master)](https://github.com/Workiva/react-dart/actions?query=workflow%3A%22Dart+CI%22+branch%3Amaster)
[![React Dart API Docs](https://img.shields.io/badge/api_docs-react-blue.svg)](https://pub.dev/documentation/react/latest/)

Expand All @@ -11,7 +11,7 @@ _Thanks to the folks at [Vacuumlabs](https://www.vacuumlabs.com/) for creating t

### Installation

If you are not familiar with the ReactJS library, read this [react tutorial](http://facebook.github.io/react/docs/getting-started.html) first.
If you are not familiar with the ReactJS library, read this [react tutorial](https://reactjs.org/docs/getting-started.html) first.

1. Install the Dart SDK

Expand All @@ -25,9 +25,9 @@ If you are not familiar with the ReactJS library, read this [react tutorial](htt
name: your_package_name
version: 1.0.0
environment:
sdk: ^2.0.0
sdk: ^2.7.0
dependencies:
react: ^5.0.0
react: ^6.0.0
```

3. Install the dependencies using pub:
Expand Down Expand Up @@ -123,10 +123,10 @@ var aButton = button({"onClick": (SyntheticMouseEvent event) => print(event)});
2. Then register the class so ReactJS can recognize it.

```dart
var CoolWidget = registerComponent(() => new CoolWidgetComponent());
var CoolWidget = registerComponent2(() => CoolWidgetComponent());
```

> __Warning:__ `registerComponent` should be called only once per component and lifetime of application.
> __Warning:__ `registerComponent2` should be called only once per component and lifetime of application.

3. Then you can use the registered component similarly as native elements.

Expand Down Expand Up @@ -159,7 +159,7 @@ class CoolWidgetComponent extends Component2 {
}
}

var CoolWidget = registerComponent(() => new CoolWidgetComponent());
var CoolWidget = registerComponent2(() => CoolWidgetComponent());
```

```dart
Expand All @@ -181,14 +181,14 @@ main() {

> __Note:__ The typed interface capabilities of this library are fairly limited, and can result in
extremely verbose implementations. We strongly recommend using the
[OverReact](https://pub.dartlang.org/packages/over_react) package - which
[OverReact](https://pub.dev/packages/over_react) package - which
makes creating statically-typed React UI components using Dart easy.

```dart
// cool_widget.dart
typedef CoolWidgetType({String headline, String text, int counter});

var _CoolWidget = registerComponent(() => new CoolWidgetComponent());
var _CoolWidget = registerComponent2(() => CoolWidgetComponent());

CoolWidgetType CoolWidget({String headline, String text, int counter}) {
return _CoolWidget({'headline':headline, 'text':text});
Expand Down Expand Up @@ -286,7 +286,7 @@ If you want to work with DOM nodes of dart or JS components instead,
you can call top level `findDOMNode` on anything the ref returns.

```dart
var DartComponent = registerComponent(() => new _DartComponent());
var DartComponent = registerComponent2(() => _DartComponent());
class _DartComponent extends Component2 {
@override
render() => div({});
Expand All @@ -296,16 +296,16 @@ class _DartComponent extends Component2 {
}
}

var ParentComponent = registerComponent(() => new _ParentComponent());
var ParentComponent = registerComponent2(() => _ParentComponent());
class _ParentComponent extends Component2 {
InputElement inputRef; // Returns the DOM node.
_DartComponent dartComponentRef; // Returns instance of _DartComponent
final inputRef = createRef<InputElement>(); // inputRef.current is the DOM node.
final dartComponentRef = createRef<_DartComponent>(); // dartComponentRef.current is the instance of _DartComponent

@override
void componentDidMount() {
print(inputRef.value); // Prints "hello" to the console.
print(inputRef.current.value); // Prints "hello" to the console.

dartComponentRef.someInstanceMethod(5); // Calls the method defined in _DartComponent
dartComponentRef.current.someInstanceMethod(5); // Calls the method defined in _DartComponent
react_dom.findDOMNode(dartComponentRef); // Returns div element rendered from _DartComponent

react_dom.findDOMNode(this); // Returns root dom element rendered from this component
Expand All @@ -314,26 +314,26 @@ class _ParentComponent extends Component2 {
@override
render() {
return div({},
input({"ref": (ref){ inputRef = ref; }, "defaultValue": "hello"}),
DartComponent({"ref": (ref) { dartComponentRef = ref; }}),
input({"ref": inputRef, "defaultValue": "hello"}),
DartComponent({"ref": dartComponentRef}),
);
}
}
```

### Example Application

For more robust examples take a look at our [examples](https://github.com/cleandart/react-dart/tree/master/example).
For more robust examples take a look at our [examples](https://github.com/Workiva/react-dart/tree/master/example).



## Unit Testing Utilities

[lib/react_test_utils.dart](https://github.com/cleandart/react-dart/blob/master/lib/react_test_utils.dart) is a
[lib/react_test_utils.dart](https://github.com/Workiva/react-dart/blob/master/lib/react_test_utils.dart) is a
Dart wrapper for the [ReactJS TestUtils](https://reactjs.org/docs/test-utils.html) library allowing for unit tests
to be made for React components in Dart.

Here is an example of how to use React React.addons.TestUtils. within a Dart test.
Here is an example of how to use `package:react/react_test_utils.dart` within a Dart test.

```dart
import 'package:test/test.dart';
Expand All @@ -354,7 +354,7 @@ class MyTestComponent extends react.Component2 {
}
}

var myTestComponent = react.registerComponent(() => new MyTestComponent());
var myTestComponent = react.registerComponent2(() => new MyTestComponent());

void main() {
test('should click button and set span text to "success"', () {
Expand Down Expand Up @@ -391,61 +391,36 @@ Format using
dartfmt -l 120 -w .
```

While we'd like to adhere to the recommended line length of 80, it's too too short for much of the code
While we'd like to adhere to the recommended line length of 80, it's too short for much of the code
repo written before a formatter was use, causing excessive wrapping and code that's hard to read.

So, we us a line length of 120 instead.
So, we use a line length of 120 instead.

### Running Tests

#### Dart 2: dart2js
#### dart2js

```bash
pub run test -p chrome
```
_Or any other browser, e.g. `-p firefox`._

#### Dart 2: Dart Dev Compiler ("DDC")
#### Dart Dev Compiler ("DDC")

```bash
pub run build_runner test -- -p chrome
```
_DDC only works in chrome._

#### Dart 1: Dart VM

```bash
pub run test -p content-shell
```

#### Dart 1: dart2js

```bash
pub run test -p chrome
```
_Or any other browser platform, e.g. `-p firefox`._

#### Dart 1: Dart Dev Compiler ("DDC")

1. In one terminal, serve the test directory using the dev compiler:
```bash
pub serve test --port=8090 --web-compiler=dartdevc
```
2. In another terminal, run the tests, referencing the port the dev compiler is using to serve the test directory:
```bash
pub run test -p chrome --pub-serve=8090
```
_DDC only works in chrome._

### Building React JS Source Files

Make sure the packages you need are dependencies in `package.json` then run:
```bash
npm install
yarn install
```

After modifying files any files in ./js_src/, run:

```bash
npm run build
yarn run build
```
8 changes: 8 additions & 0 deletions aviary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 1

exclude:
- ^example/
- ^test/
- ^tool/
- # Ignore compiled JS files and source maps
- ^lib/react\w*\.js(\.map)?$
11 changes: 8 additions & 3 deletions js_src/_dart_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ function _createReactDartComponentClass2(dartInteropStatics, componentStatics, j
}

static getDerivedStateFromProps(nextProps, prevState) {
// Must call checkPropTypes manually because React moved away from using the `prop-types` package.
// See: https://github.com/facebook/react/pull/18127
// React now uses its own internal cache of errors for PropTypes which broke `PropTypes.resetWarningCache()`.
// Solution was to use `PropTypes.checkPropTypes` directly which makes `PropTypes.resetWarningCache()` work.
// Solution from: https://github.com/facebook/react/issues/18251#issuecomment-609024557
if (process.env.NODE_ENV !== 'production') {
React.PropTypes.checkPropTypes(jsConfig.propTypes, nextProps, 'prop', ReactDartComponent2.displayName);
}
let derivedState = dartInteropStatics.handleGetDerivedStateFromProps(componentStatics, nextProps, prevState);
return typeof derivedState !== 'undefined' ? derivedState : null;
}
Expand Down Expand Up @@ -153,9 +161,6 @@ function _createReactDartComponentClass2(dartInteropStatics, componentStatics, j
if (jsConfig.defaultProps) {
ReactDartComponent2.defaultProps = jsConfig.defaultProps;
}
if (jsConfig.propTypes) {
ReactDartComponent2.propTypes = jsConfig.propTypes;
}
}

return ReactDartComponent2;
Expand Down
20 changes: 20 additions & 0 deletions js_src/dart_env_dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,23 @@ if (typeof window.MemoryInfo == "undefined") {
window.MemoryInfo.prototype = window.performance.memory.__proto__;
}
}

// Intercept console.warn calls and prevent excessive warnings in DDC-compiled code
// when type-checking event handlers (function types that include SyntheticEvent classes).
//
// These warnings are a result of a workaround to https://github.com/dart-lang/sdk/issues/43939
const oldConsoleWarn = console.warn;
let hasWarned = false;
console.warn = function() {
const firstArg = arguments[0];
// Use startsWith instead of indexOf as a small optimization for when large strings are logged.
if (typeof firstArg === 'string' && firstArg.startsWith('Cannot find native JavaScript type (Synthetic')) {
if (!hasWarned) {
hasWarned = true;
oldConsoleWarn.apply(console, arguments);
oldConsoleWarn('The above warning is expected and is the result of a workaround to https://github.com/dart-lang/sdk/issues/43939');
}
} else {
oldConsoleWarn.apply(console, arguments);
}
}
3 changes: 3 additions & 0 deletions js_src/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import 'core-js/es/set';
import 'core-js/stable/reflect/delete-property';
import 'core-js/stable/object/assign';

// Used by dart_env_dev.js
import 'core-js/stable/string/starts-with';

// Additional polyfills are included by core-js based on 'usage' and browser requirements

// Custom dart side methods
Expand Down
Loading