Skip to content

Commit ad5e8c8

Browse files
committed
Update imperative to declarative exercise instructions
1 parent fd979d2 commit ad5e8c8

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

subjects/05-Imperative-to-Declarative/exercise-no-bootstrap.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
////////////////////////////////////////////////////////////////////////////////
22
// Exercise:
33
//
4-
// - rename this file to exercise.js or copy paste it there to get it to run
5-
// - even though this Modal is a React component, the author created an
4+
// - Rename this file to exercise.js or copy paste it there to get it to run
5+
// - Even though this Modal is a React component, the author created an
66
// imperative API D: Make it declarative!
77
////////////////////////////////////////////////////////////////////////////////
88
import React from "react";
@@ -53,11 +53,11 @@ class Modal extends React.Component {
5353

5454
class App extends React.Component {
5555
openModal = () => {
56-
this.refs.modal.open();
56+
this.modal.open();
5757
};
5858

5959
closeModal = () => {
60-
this.refs.modal.close();
60+
this.modal.close();
6161
};
6262

6363
render() {
@@ -79,7 +79,7 @@ class App extends React.Component {
7979
same curve, just on opposite ends.
8080
</p>
8181

82-
<Modal ref="modal">
82+
<Modal ref={modal => (this.modal = modal)}>
8383
<button onClick={this.closeModal}>close</button>
8484
<p>Are you sure?</p>
8585
</Modal>

subjects/05-Imperative-to-Declarative/exercise.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
////////////////////////////////////////////////////////////////////////////////
22
// Exercise:
33
//
4-
// This Modal, even though its a React component, has an imperative API to
5-
// open and close it. Can you convert it to a declarative API?
4+
// - This Modal, even though its a React component, has an imperative API
5+
// to open and close it. Can you convert it to a declarative API?
6+
//
7+
// Got extra time?
8+
//
9+
// - What happens when you click the overlay? How can you keep the state of
10+
// the <App> consistent with what you see in the page?
611
////////////////////////////////////////////////////////////////////////////////
712
import $ from "jquery";
813
import "bootstrap";

subjects/05-Imperative-to-Declarative/solution.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
////////////////////////////////////////////////////////////////////////////////
22
// Exercise:
33
//
4-
// This Modal, even though its a React component, has an imperative API to
5-
// open and close it. Can you convert it to a declarative API?
4+
// - This Modal, even though its a React component, has an imperative API
5+
// to open and close it. Can you convert it to a declarative API?
6+
//
7+
// Got extra time?
8+
//
9+
// - What happens when you click the overlay? How can you keep the state of
10+
// the <App> consistent with what you see in the page?
611
////////////////////////////////////////////////////////////////////////////////
712
import $ from "jquery";
813
import "bootstrap";

0 commit comments

Comments
 (0)