Skip to content

Commit e8131ea

Browse files
committed
docs: simplify Transition code example with hooks
1 parent 332fc64 commit e8131ea

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/Transition.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,23 @@ export const EXITING = 'exiting'
7272
* begins the "Enter" stage. During this stage, the component will shift from
7373
* its current transition state, to `'entering'` for the duration of the
7474
* transition and then to the `'entered'` stage once it's complete. Let's take
75-
* the following example:
75+
* the following example (we'll use the
76+
* [useState](https://reactjs.org/docs/hooks-reference.html#usestate) hook):
7677
*
7778
* ```jsx
78-
* state = { in: false };
79-
*
80-
* toggleEnterState = () => {
81-
* this.setState({ in: true });
82-
* }
83-
*
84-
* render() {
79+
* function App() {
80+
* const [inProp, setInProp] = useState(false);
8581
* return (
86-
* <>
87-
* <Transition in={this.state.in} timeout={500}>
82+
* <div>
83+
* <Transition in={inProp} timeout={500}>
8884
* {state => (
8985
* // ...
9086
* )}
9187
* </Transition>
92-
* <button onClick={this.toggleEnterState}>Click to Enter</button>
93-
* </>
88+
* <button onClick={() => setInProp(true)}>
89+
* Click to Enter
90+
* </button>
91+
* </div>
9492
* );
9593
* }
9694
* ```

0 commit comments

Comments
 (0)