Skip to content

Commit 44ffabc

Browse files
Update react_dom location and other feedback
1 parent 1234e58 commit 44ffabc

File tree

5 files changed

+53
-39
lines changed

5 files changed

+53
-39
lines changed

lib/react_dom.dart

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Workiva Inc.
1+
// Copyright 2025 Workiva Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -25,36 +25,4 @@
2525
/// import 'package:over_react/over_react.dart';
2626
library over_react.react_dom;
2727

28-
import 'dart:html';
29-
30-
import 'package:over_react/over_react.dart';
31-
import 'package:react/react_dom.dart' as react_dom show render, unmountComponentAtNode;
32-
33-
/// Renders the provided [element] into the DOM mounted in the provided [mountNode]
34-
/// and returns a reference to it based on its type:
35-
///
36-
/// 1. Returns an [Element] if [element] is a DOM component _(e.g. [Dom.div])_.
37-
/// 2. Returns a React `Component` if [element] is a composite component.
38-
///
39-
/// > __Throws__ if [element] or [mountNode] are `null`.
40-
///
41-
/// If the [element] was previously rendered into the [mountNode], this will perform an update on it and only
42-
/// mutate the DOM as necessary to reflect the latest React component.
43-
///
44-
/// Use [unmountComponentAtNode] to unmount the instance.
45-
///
46-
/// > Proxies [react_dom.render].
47-
dynamic render(ReactNode element, Element mountNode) {
48-
return react_dom.render(element, mountNode);
49-
}
50-
51-
/// Removes a React `Component` from the DOM that was mounted via [render]
52-
/// and cleans up its event handlers and state.
53-
///
54-
/// * Returns `false` if a `Component` was not mounted in the [mountNode].
55-
/// * Returns `true` if a `Component` was mounted in the [mountNode].
56-
///
57-
/// > Proxies [react_dom.unmountComponentAtNode].
58-
bool unmountComponentAtNode(Element mountNode) {
59-
return react_dom.unmountComponentAtNode(mountNode) as bool;
60-
}
28+
export 'package:over_react/src/react_dom.dart' show render, unmountComponentAtNode;

lib/src/component/aria_mixin.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ library over_react.aria_mixin;
1616

1717
import 'dart:collection';
1818

19+
import 'package:over_react/src/component_declaration/annotations.dart';
1920
// Must import these consts because they are used in the transformed code.
2021
// ignore: unused_shown_name
21-
import 'package:over_react/over_react.dart' show PropDescriptor, PropsMeta;
22-
import 'package:over_react/src/component_declaration/annotations.dart';
22+
import 'package:over_react/src/component_declaration/component_base.dart' show PropDescriptor, PropsMeta;
2323

2424
part 'aria_mixin.over_react.g.dart';
2525

lib/src/react_dom.dart

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2025 Workiva Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
import 'dart:html';
15+
16+
import 'package:over_react/src/component/dom_components.dart';
17+
import 'package:react/react_client.dart' show ReactNode;
18+
import 'package:react/react_dom.dart' as react_dom show render, unmountComponentAtNode;
19+
20+
/// Renders the provided [element] into the DOM mounted in the provided [mountNode]
21+
/// and returns a reference to it based on its type:
22+
///
23+
/// 1. Returns an [Element] if [element] is a DOM component _(e.g. [Dom.div])_.
24+
/// 2. Returns a React `Component` if [element] is a composite component.
25+
///
26+
/// > __Throws__ if [element] or [mountNode] are `null`.
27+
///
28+
/// If the [element] was previously rendered into the [mountNode], this will perform an update on it and only
29+
/// mutate the DOM as necessary to reflect the latest React component.
30+
///
31+
/// Use [unmountComponentAtNode] to unmount the instance.
32+
///
33+
/// > Proxies [react_dom.render].
34+
dynamic render(ReactNode element, Element mountNode) {
35+
return react_dom.render(element, mountNode);
36+
}
37+
38+
/// Removes a React `Component` from the DOM that was mounted via [render]
39+
/// and cleans up its event handlers and state.
40+
///
41+
/// * Returns `false` if a `Component` was not mounted in the [mountNode].
42+
/// * Returns `true` if a `Component` was mounted in the [mountNode].
43+
///
44+
/// > Proxies [react_dom.unmountComponentAtNode].
45+
bool unmountComponentAtNode(Element mountNode) {
46+
return react_dom.unmountComponentAtNode(mountNode) as bool;
47+
}

lib/src/util/rem_util.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ import 'package:meta/meta.dart';
2323
import 'package:over_react/src/component/dom_components.dart';
2424
import 'package:over_react/src/component/resize_sensor.dart' as v2;
2525
import 'package:over_react/src/component_declaration/component_base.dart' as component_base;
26+
import 'package:over_react/src/react_dom.dart' as react_dom;
2627
import 'package:over_react/src/util/css_value_util.dart';
2728
import 'package:platform_detect/platform_detect.dart';
2829

29-
import '../../react_dom.dart' as react_dom;
30-
3130
// The computed font size of the HTML node isn't reliable in Chrome when the page is refreshed while zoomed.
3231
// Instead, measure a container to determine how big 1rem is.
3332
//

lib/src/util/safe_render_manager/safe_render_manager.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ import 'dart:async';
1616
import 'dart:html';
1717

1818
import 'package:over_react/src/component/ref_util.dart';
19+
import 'package:over_react/src/react_dom.dart' as react_dom;
1920
import 'package:react/react_client.dart'
2021
show
2122
ReactElement;
2223
import 'package:w_common/disposable.dart';
2324

24-
import '../../../react_dom.dart' as react_dom;
2525
import './safe_render_manager_helper.dart';
2626

2727
/// A class that manages the top-level rendering of a [ReactElement] into a given node,

0 commit comments

Comments
 (0)