-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
chore: update React examples to match with the new React guidelines #12217
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
15 commits
Select commit
Hold shift + click to select a range
fad5df4
Refactor examples/react
charpeni 5b8fd63
Refactor examples/react-testing-library
charpeni 3a9cd02
Refactor examples/snapshot
charpeni f82f133
Refactor examples/typescript
charpeni 8057683
Refactor examples/enzyme
charpeni 07ecfbd
Remove unused React imports
charpeni 922c6b4
Refactor docs/TutorialReact.md
charpeni 54d0402
Refactor docs/SnapshotTesting.md
charpeni d2fcf01
Mention React 16+
charpeni c4617fc
Keep snapshot example short
charpeni 4504eea
Add CHANGELOG entry
charpeni 6e197ac
Rerun Prettier
charpeni 707f8b1
Revert to .react.js file convention
charpeni f6aa020
Merge branch 'main' into refactor-to-new-react-style
charpeni 947f7de
Merge branch 'main' into refactor-to-new-react-style
SimenB 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
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,6 +1,8 @@ | ||
| // Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
|
|
||
| module.exports = { | ||
| presets: ['@babel/preset-env', '@babel/preset-react'], | ||
| plugins: ['@babel/plugin-proposal-class-properties'] | ||
| presets: [ | ||
| '@babel/preset-env', | ||
| ['@babel/preset-react', {runtime: 'automatic'}], | ||
| ], | ||
| }; |
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,26 +1,28 @@ | ||
| // Copyright 2004-present Facebook. All Rights Reserved. | ||
|
|
||
| import React from 'react'; | ||
| import {useState} from 'react'; | ||
|
|
||
| export default class CheckboxWithLabel extends React.Component { | ||
| state = { | ||
| isChecked: false, | ||
| }; | ||
| export default function CheckboxWithLabel({ | ||
| labelRef, | ||
| inputRef, | ||
| labelOn, | ||
| labelOff, | ||
| }) { | ||
| const [isChecked, setIsChecked] = useState(false); | ||
|
|
||
| onChange = () => { | ||
| this.setState({isChecked: !this.state.isChecked}); | ||
| const onChange = () => { | ||
| setIsChecked(!isChecked); | ||
| }; | ||
|
|
||
| render() { | ||
| return ( | ||
| <label> | ||
| <input | ||
| type="checkbox" | ||
| checked={this.state.isChecked} | ||
| onChange={this.onChange} | ||
| /> | ||
| {this.state.isChecked ? this.props.labelOn : this.props.labelOff} | ||
| </label> | ||
| ); | ||
| } | ||
| return ( | ||
| <label ref={labelRef}> | ||
| <input | ||
| ref={inputRef} | ||
| type="checkbox" | ||
| checked={isChecked} | ||
| onChange={onChange} | ||
| /> | ||
| {isChecked ? labelOn : labelOff} | ||
| </label> | ||
| ); | ||
| } |
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,6 +1,8 @@ | ||
| // Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
|
|
||
| module.exports = { | ||
| presets: ['@babel/preset-env', '@babel/preset-react'], | ||
| plugins: ['@babel/plugin-proposal-class-properties'], | ||
| presets: [ | ||
| '@babel/preset-env', | ||
| ['@babel/preset-react', {runtime: 'automatic'}], | ||
| ], | ||
| }; |
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
1 change: 0 additions & 1 deletion
1
examples/react-testing-library/__tests__/CheckboxWithLabel-test.js
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,5 +1,8 @@ | ||
| // Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
|
|
||
| module.exports = { | ||
| presets: ['@babel/preset-env', '@babel/preset-react'], | ||
| presets: [ | ||
| '@babel/preset-env', | ||
| ['@babel/preset-react', {runtime: 'automatic'}], | ||
| ], | ||
| }; |
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,6 +1,8 @@ | ||
| // Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
|
|
||
| module.exports = { | ||
| presets: ['@babel/preset-env', '@babel/preset-react'], | ||
| plugins: ['@babel/plugin-proposal-class-properties'], | ||
| presets: [ | ||
| '@babel/preset-env', | ||
| ['@babel/preset-react', {runtime: 'automatic'}], | ||
| ], | ||
| }; |
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
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.
Uh oh!
There was an error while loading. Please reload this page.