File tree Expand file tree Collapse file tree 3 files changed +19
-9
lines changed
subjects/05-Imperative-to-Declarative Expand file tree Collapse file tree 3 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 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////////////////////////////////////////////////////////////////////////////////
88import React from "react" ;
@@ -53,11 +53,11 @@ class Modal extends React.Component {
5353
5454class 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 >
Original file line number Diff line number Diff line change 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////////////////////////////////////////////////////////////////////////////////
712import $ from "jquery" ;
813import "bootstrap" ;
Original file line number Diff line number Diff line change 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////////////////////////////////////////////////////////////////////////////////
712import $ from "jquery" ;
813import "bootstrap" ;
You can’t perform that action at this time.
0 commit comments