-
Notifications
You must be signed in to change notification settings - Fork 57
CPLAT-4304 Expose React Fragments #303
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
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d8a837a
Add initial wrapper
joebingham-wk 1428798
Add dependency to pubspec
joebingham-wk 6467eb4
Pull fragment from react.dart
joebingham-wk 04b1cc4
Add tests
sydneyjodon-wk 0ccd3b3
Remove build_daemon
joebingham-wk f486aa7
Merge branch 'CPLAT-4304-react-fragments' of github.com:Workiva/over_…
joebingham-wk 4e239e1
Update based on reviewer feedback
sydneyjodon-wk cd81ab0
Merge branch 'CPLAT-4304-react-fragments' of github.com:Workiva/over_…
sydneyjodon-wk 2d81710
Update comments
sydneyjodon-wk 53c8a3b
Remove componentFactory argument
sydneyjodon-wk b981614
Update formatting
sydneyjodon-wk 4151d76
Update copyright comments
sydneyjodon-wk 36493cb
Upgrade to analyzer 0.36.x and build_web_compilers 2.x
evanweible-wf 2c5d104
Remove coverage dep as it is currently unused.
evanweible-wf 34c1543
Add dev_dep on build_resolvers.
evanweible-wf 036128a
Update base image to Dart2.4
evanweible-wf 00cd90e
Merge pull request #310 from Workiva/dart24_bwc2
rmconsole2-wf 12e2898
over_react_2.4.4+dart2
rmconsole-readonly-wk 388c7ea
Changelog entry for v2.4.4
evanweible-wf 327f177
Merge pull request #313 from Workiva/release_over_react_2.4.4+dart2
rmconsole6-wk 14cdc6e
Merge branch 'master' into CPLAT-4304-react-fragments
kealjones-wk 019be24
merge master and revert pubspec
kealjones-wk 8292047
Merge branch '3.1.0-wip' into CPLAT-4304-react-fragments
kealjones-wk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FROM google/dart:2.1.0 | ||
| FROM google/dart:2.4 | ||
|
|
||
| # Expose env vars for git ssh access | ||
| ARG GIT_SSH_KEY | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // Copyright 2019 Workiva Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| import 'package:over_react/src/component_declaration/component_base.dart' | ||
| as component_base; | ||
| import 'package:over_react/src/component_declaration/builder_helpers.dart' | ||
| as builder_helpers; | ||
| import 'package:react/react_client.dart'; | ||
| import 'package:react/src/react_client/js_backed_map.dart'; | ||
| import 'package:react/react.dart' as react; | ||
|
|
||
| class FragmentProps extends component_base.UiProps | ||
| with builder_helpers.GeneratedClass | ||
| implements builder_helpers.UiProps { | ||
| // Initialize to a JsBackedMap so that copying can be optimized | ||
| // when converting props during ReactElement creation. | ||
| FragmentProps([Map props]) : this.props = props ?? new JsBackedMap(); | ||
|
|
||
| @override | ||
| ReactJsComponentFactoryProxy componentFactory = react.Fragment; | ||
|
|
||
| @override | ||
| final Map props; | ||
|
|
||
| @override | ||
| String get propKeyNamespace => ''; | ||
| } | ||
|
|
||
| /// Fragment component that allows the wrapping of children without the necessity of using | ||
| /// an element that adds an additional layer to the DOM (div, span, etc). | ||
| /// | ||
| /// See: <https://reactjs.org/docs/fragments.html> | ||
| FragmentProps Fragment() => new FragmentProps(); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Copyright 2019 Workiva Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| import 'package:over_react/over_react.dart'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file needs the copyright block: // Copyright 2019 Workiva Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License. |
||
|
|
||
| // ignore: uri_has_not_been_generated | ||
| part 'dummy_component.over_react.g.dart'; | ||
|
|
||
| @Factory() | ||
| // ignore: undefined_identifier | ||
| UiFactory<DummyProps> Dummy = _$Dummy; | ||
|
|
||
| @Props() | ||
| class _$DummyProps extends UiProps { | ||
| Function onComponentDidMount; | ||
| } | ||
|
|
||
| // AF-3369 This will be removed once the transition to Dart 2 is complete. | ||
| // ignore: mixin_of_non_class, undefined_class | ||
| class DummyProps extends _$DummyProps with _$DummyPropsAccessorsMixin { | ||
| // ignore: undefined_identifier, undefined_class, const_initialized_with_non_constant_value | ||
| static const PropsMeta meta = _$metaForDummyProps; | ||
| } | ||
|
|
||
| @Component2() | ||
| class DummyComponent extends UiComponent2<DummyProps> { | ||
| @override | ||
| void componentDidMount() { | ||
| props.onComponentDidMount(); | ||
| } | ||
|
|
||
| @override | ||
| render() { | ||
| return (Dom.button()..addTestId('DummyButton'))('oh hai'); | ||
| } | ||
| } | ||
151 changes: 151 additions & 0 deletions
151
test/over_react/component/fixtures/dummy_component.over_react.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| // Copyright 2019 Workiva Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| library fragment_component_test; | ||
|
|
||
| import 'package:over_react/over_react.dart'; | ||
| import 'package:over_react_test/over_react_test.dart'; | ||
| import 'package:test/test.dart'; | ||
|
|
||
| import 'fixtures/dummy_component.dart'; | ||
|
|
||
| void main() { | ||
| group('Fragment', () { | ||
| test('renders only its children', () { | ||
| var wrappingDivRef; | ||
|
|
||
| renderAttachedToDocument( | ||
| (Dom.div() | ||
| ..ref = (ref) { | ||
| wrappingDivRef = ref; | ||
| })(Fragment()( | ||
| Dom.div()(), | ||
| Dom.div()(), | ||
| Dom.div()(), | ||
| Dom.div()(), | ||
| )), | ||
| ); | ||
|
|
||
| expect(wrappingDivRef.children, hasLength(4)); | ||
| }); | ||
|
|
||
| test('passes the key properly onto the fragment', () { | ||
| var callCount = 0; | ||
| var jacket = mount( | ||
| (Fragment()..key = 1)( | ||
| (Dummy() | ||
| ..onComponentDidMount = () { | ||
| callCount++; | ||
| })(), | ||
| ), | ||
| ); | ||
|
|
||
| expect(callCount, 1); | ||
|
|
||
| jacket.rerender( | ||
| (Fragment()..key = 2)( | ||
| (Dummy() | ||
| ..onComponentDidMount = () { | ||
| callCount++; | ||
| })(), | ||
| ), | ||
| ); | ||
|
|
||
| expect(callCount, 2, | ||
| reason: | ||
| 'Dummy should have been remounted as a result of Fragment key changing'); | ||
| }); | ||
| }); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file needs the copyright block: