Skip to content

Commit d7487fb

Browse files
audetyroprogrammer
andauthored
Improve wording throughout tutorial (#52)
Co-authored-by: Ganesh Bhattarai <[email protected]>
1 parent ba6b137 commit d7487fb

16 files changed

+116
-113
lines changed

src/capstone/Capstone.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const EMPTY_TICKER_MSG = 'Please type a stock ticker and click Search button.';
1010

1111
/**
1212
* 🏆
13-
* The goal of this capstone project is to bring together most of the
13+
* The goal of this capstone project is to bring together most of the
1414
* concepts you have learned in this tutorial together by building this feature.
1515
* The feature we are building is pretty straight forward. There's an input
1616
* field and a search button. When the user types in a valid stock ticker and
@@ -32,7 +32,7 @@ class Capstone extends Component {
3232
handleSearch(stockTicker) {
3333
/**
3434
* ✏️
35-
* When this method is called, it will be given a stockTicker
35+
* When this method is called, it will be given a stockTicker
3636
* as an argument. You need to call setState to set the stockTicker
3737
* state to the value provided to this function
3838
*/
@@ -48,7 +48,7 @@ class Capstone extends Component {
4848
* Like: isEmpty(this.state.stockTicker)
4949
* 🧭 If it is empty assign <div>{EMPTY_TICKER_MSG}</div> to EmptyTickerMessage
5050
* 🧭 If the stockTicker is not empty assign null to EmptyTickerMessage
51-
* You can either use ternery operator -
51+
* You can either use ternery operator -
5252
* const a = isEmpty(b) ? c : null;
5353
* OR you can use '&&' operator -
5454
* const a = isEmpty(b) && c;

src/capstone/CompanyFinancial.jsx

+18-18
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,24 @@ class CompanyFinancial extends Component {
5656
* every time either the props changes or the state changes for this component
5757
*/
5858
componentDidUpdate(prevProps, prevState) {
59-
/**
60-
* ✏️
61-
* You need to call the fetchCompanyFinancial method to fetch the
62-
* comanyFinancial data when the parent passes you a different stockTicker
63-
* 🧭 Remember to check if the stockTicker props changed before calling the
64-
* fetchCompanyFinancial method though. You DON'T want to fetch the data
65-
* if the stockTicker hasn't changed. If you don't check whether props
66-
* changed your component will go in an infinite loop - it will be
67-
* fetching the same data over and over again.
68-
* This lifecycle method will be given multiple arguments.
69-
* First argument is the value of props before this component updated
70-
* Second argument is the value of the state before this component updated
71-
* In our case we just want to check props to see if value for stockTicker
72-
* changed and the way to do this is:
73-
* if (this.props.stockTicker !== prevProps.stockTicker) {
74-
* //Fetch data here only if the current props is not same as previous props
75-
* }
76-
*/
59+
/**
60+
* ✏️
61+
* You need to call the fetchCompanyFinancial method to fetch the
62+
* comanyFinancial data when the parent passes you a different stockTicker
63+
* 🧭 Remember to check if the stockTicker props changed before calling the
64+
* fetchCompanyFinancial method though. You DON'T want to fetch the data
65+
* if the stockTicker hasn't changed. If you don't check whether props
66+
* changed your component will go in an infinite loop - it will be
67+
* fetching the same data over and over again.
68+
* This lifecycle method will be given multiple arguments.
69+
* First argument is the value of props before this component updated
70+
* Second argument is the value of the state before this component updated
71+
* In our case we just want to check props to see if value for stockTicker
72+
* changed and the way to do this is:
73+
* if (this.props.stockTicker !== prevProps.stockTicker) {
74+
* //Fetch data here only if the current props is not same as previous props
75+
* }
76+
*/
7777
}
7878

7979
/**

src/capstone/CompanyProfile.jsx

+24-24
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,38 @@ class CompanyProfile extends Component {
4949
*/
5050
}
5151

52-
/*
52+
/**
5353
* 💡
5454
* This is another lifecycle method. React will invoke this lifecyle method
5555
* after the component is updated. Remember the component will be updated
5656
* every time either the props changes or the state changes for this component
5757
*/
5858
componentDidUpdate(prevProps, prevState) {
59-
/**
60-
* ✏️
61-
* You need to call the fetchCompanyProfile method to fetch the
62-
* comanyProfile data when the parent passes you a different stockTicker
63-
* 🧭 Remember to check if the stockTicker props changed before calling the
64-
* fetchCompanyProfile method though. You DON'T want to fetch the data
65-
* if the stockTicker hasn't changed. If you don't check whether props
66-
* changed your component will go in an infinite loop - it will be
67-
* fetching the same data over and over again.
68-
* This lifecycle method will be given multiple arguments.
69-
* First argument is the value of props before this component updated
70-
* Second argument is the value of the state before this component updated
71-
* In our case we just want to check props to see if value for stockTicker
72-
* changed and the way to do this is:
73-
* if (this.props.stockTicker !== prevProps.stockTicker) {
74-
* //Fetch data here only if the current props is not same as previous props
75-
* }
76-
*/
59+
/**
60+
* ✏️
61+
* You need to call the fetchCompanyProfile method to fetch the
62+
* comanyProfile data when the parent passes you a different stockTicker
63+
* 🧭 Remember to check if the stockTicker props changed before calling the
64+
* fetchCompanyProfile method though. You DON'T want to fetch the data
65+
* if the stockTicker hasn't changed. If you don't check whether props
66+
* changed your component will go in an infinite loop - it will be
67+
* fetching the same data over and over again.
68+
* This lifecycle method will be given multiple arguments.
69+
* First argument is the value of props before this component updated
70+
* Second argument is the value of the state before this component updated
71+
* In our case we just want to check props to see if value for stockTicker
72+
* changed and the way to do this is:
73+
* if (this.props.stockTicker !== prevProps.stockTicker) {
74+
* //Fetch data here only if the current props is not same as previous props
75+
* }
76+
*/
7777
}
7878

7979
/**
8080
* 💡
8181
* This is a method to fetch the company profile data from the API.
8282
* Couple things to note here:
83-
* 1. We are updating the errorMsg state to empty string. This is jus to
83+
* 1. We are updating the errorMsg state to empty string. This is jus to
8484
* reset any error message we might have from previous search
8585
* 2. We invoke the API only when the stockTicker is truthy. No point in
8686
* calling the API if we don't have any value for stockTicker
@@ -104,7 +104,7 @@ class CompanyProfile extends Component {
104104
* Updates the companyProfile state with the argument provided
105105
*/
106106
updateCompanyProfile(companyProfile) {
107-
this.setState({ companyProfile })
107+
this.setState({ companyProfile });
108108
}
109109

110110
/**
@@ -135,15 +135,15 @@ class CompanyProfile extends Component {
135135
/**
136136
* ✏️
137137
* We want to render an error message if the API returns some error.
138-
* We want to check if we have `errorMsg` state is not empty and
138+
* We want to check if we have `errorMsg` state is not empty and
139139
* if it's not render the message inside a div
140140
* 🧭 There's an `isEmpty` function that's already imported. Use that
141141
* to check if the `errorMsg` state is empty
142142
* Like: isEmpty(this.state.errorMsg)
143143
* 🧭 If it is empty assign null to ErrorMsg
144144
* 🧭 If the errorMsg is not empty assign <div>{this.state.errorMsg}</div>
145145
* to the ErrorMsg constant.
146-
* You can either use ternery operator -
146+
* You can either use ternery operator -
147147
* const a = isEmpty(b) ? c : null;
148148
* OR you can use '&&' operator -
149149
* const a = isEmpty(b) && c;
@@ -156,7 +156,7 @@ class CompanyProfile extends Component {
156156
* 💡
157157
* Here we are doing same thing as the ErrorMsg above
158158
* Instead of checking for `errorMsg` we are checking for `companyProfile`
159-
* state. We are displaying the `div` only if the `companyProfile`
159+
* state. We are displaying the `div` only if the `companyProfile`
160160
* state is not empty.
161161
*/
162162

src/capstone/Search.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import style from './solution/style';
66
* This component houses the input and the Search button.
77
* When the user types in something we handle the change event and
88
* store the values typed in the input field to the state
9-
* When user clicks the Search button it will invoke a callback function
9+
* When user clicks the Search button it will invoke a callback function
1010
* that was passed to this component as a props with the latest input value
1111
* as an argument
1212
*/

src/exercise/06-LifecycleMethods.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class CompanyProfile extends Component {
6868

6969
/**
7070
* 🚨 🚨 DO NOT DELETE OR CHANGE THIS.🚨 🚨
71-
* This is how you would use your above component and
71+
* This is how you would use your above component and
7272
* the output of this code is displayed on the browser
7373
*/
7474
const Usage = (props) => {

src/exercise/07-HandlingEvents.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class FancyInput extends Component {
6363

6464
/**
6565
* 🚨 🚨 DO NOT DELETE OR CHANGE THIS.🚨 🚨
66-
* This is how you would use your above component
66+
* This is how you would use your above component
6767
* The output of this code is displayed on the browser on the left hand side
6868
*/
6969
const Usage = (props) => {

src/tutorial/01-HelloWorld.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ You should try this for yourself. Open the exercise file and edit the function t
2626

2727
<!--exercise-->
2828

29-
Notice that `React.createElement` is a simple javascript function which takes three arguments. First argument is the element you want to render. In our case it's a `div` element. Second argument is any properties we want to pass to that element. In our case we are not passing anything so it's null. Third argument is the children for this component. In this case it's the text we want to display - `Hello World`. So with this we are telling React to render a div element like this:
29+
Notice that `React.createElement` is a simple JavaScript function which takes three arguments. First argument is the element you want to render. In our case it's a `div` element. Second argument is any properties we want to pass to that element. In our case we are not passing anything so it's null. Third argument is the children for this component. In this case it's the text we want to display - `Hello World`. So with this we are telling React to render a div element like this:
3030

3131
```html
3232
<div>
@@ -36,11 +36,11 @@ Notice that `React.createElement` is a simple javascript function which takes th
3636

3737
Congratulations, you have created your first Hello World React component.
3838

39-
Now your inquisitive mind is probably asking - how in the world React renders this thing on the browser?
39+
Now your inquisitive mind is probably asking - how in the world does React render this thing on the browser?
4040

4141
## Rendering
4242

43-
Let's step back from React for a moment and think about how we can create the similar Hello World `div` using pure Javascript. Yes pure Javascript - without any frameworks.
43+
Let's step back from React for a moment and think about how we can create the similar Hello World `div` using pure JavaScript. Yes pure JavaScript - without any frameworks.
4444

4545
### Good Ol' Days
4646

@@ -55,7 +55,7 @@ Let's imagine you have a barebone `html` file that looks like below. It has a `d
5555
</html>
5656
```
5757

58-
Now imagine inside the `div` with id `root` we want to render another `div` that says `Hello World`. The only catch is we want to do that programmatically using pure Javascript.
58+
Now imagine inside the `div` with id `root` we want to render another `div` that says `Hello World`. The only catch is we want to do that programmatically using pure JavaScript.
5959
To achieve this we can probably do something like this:
6060

6161
```js
@@ -73,7 +73,7 @@ Here we are creating a `div` node with `Hello World` text and appending that `di
7373
We can actually write our entire application this way - creating elements, removing elements, appending elements, etc ourselves. As a matter of fact we did write applications this way before all these UI frameworks/libraries started to mushroom.
7474

7575
### Age of React
76-
A simple example like the one above are not that hard to write with pure Javascript but once your application gets bigger, it gets messier. That's where libraries like React come to the rescue - they hide away from us the messier part of rendering on the browser.
76+
A simple example like the one above are not that hard to write with pure JavaScript but once your application gets bigger, it gets messier. That's where libraries like React come to the rescue - they hide away from us the messier part of rendering on the browser.
7777

7878
The Core React library itself doesn't really know how to render anything on the browser because it is designed to work in a web browser as well as native applications. Thus the job of rendering your component on the browser is done by another library provided by React team called `ReactDOM`.
7979

@@ -85,7 +85,7 @@ ReactDOM.render(HelloWorld, document.getElementById('root'))
8585

8686
Here we are calling a function called `render` on `ReactDOM` object. The first argument of the function is the component you want to render - in our case `HelloWorld`. Second argument is a document selector. ReactDOM appends the component we want to display (first argument) as a child of the node returned by the selector (second argument).
8787

88-
Compare this solution to the pure Javascript solution we looked at earlier. With pure Javascript we were doing the DOM manipulation ourselves - creating the `div`, appending the text and appending the newly created `div` to the `div` with id `root` as its child. But with React we are not doing any DOM manipulation ourselves. Basically we are saying to React -
88+
Compare this solution to the pure JavaScript solution we looked at earlier. With pure JavaScript we were doing the DOM manipulation ourselves - creating the `div`, appending the text and appending the newly created `div` to the `div` with id `root` as its child. But with React we are not doing any DOM manipulation ourselves. Basically we are saying to React -
8989

9090
> Hey React I have a component I want to render. I will tell you what the component should look like when it's rendered (remember this is what the return of the Component function tells). I will also tell you where to render this component (second argument we passed to `ReactDOM.render` function). But I don't want to get involved in DOM manipulation - I will let you do all the DOM manipulation yourself. You can call all these DOM api like `document.createElement`, `.append`, `.appendChild` etc. whenever you wish - I trust you and I don't care as long as I see on the browser what I expected to see.
9191

src/tutorial/02-IntroToJSX.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
In the [previous section](/tutorial/hello-world) we created our first Hello World function component. Remember we returned `React.createElement` from the function to tell React what the DOM should look like when we render this component. Another alternative way of telling React what the DOM should look like is by using JSX. JSX is a very common and recommended way (preferred over `React.createElement` syntax in most cases) to write React code. JSX is a funny looking syntax though - it's not purely HTML, it's not purely Javascript. But it's an extension of Javascript where you can write HTML like syntax with full power of Javascript. For example, the equivalent of return statement we saw in [previous page](/tutorial/hello-world) (using `React.createElement`) in JSX would be:
1+
In the [previous section](/tutorial/hello-world) we created our first Hello World function component. Remember we returned `React.createElement` from the function to tell React what the DOM should look like when we render this component. Another alternative way of telling React what the DOM should look like is by using JSX. JSX is a very common and recommended way (preferred over `React.createElement` syntax in most cases) to write React code. JSX is a funny looking syntax though - it's not purely HTML, it's not purely JavaScript. But it's an extension of JavaScript where you can write HTML like syntax with full power of JavaScript. For example, the equivalent of return statement we saw in [previous page](/tutorial/hello-world) (using `React.createElement`) in JSX would be:
22

33
```jsx
44
return (
55
<div>Hello World</div>
66
)
77
```
88

9-
Instead of returning Javascript code, it's returning HTML-like code (it's not HTML) and notice it's not a string. Wait, what?!! Welcome to JSX!
9+
Instead of returning JavaScript code, it's returning HTML-like code (it's not HTML) and notice it's not a string. Wait, what?!! Welcome to JSX!
1010

1111
You don't trust that this weird syntax works, do you? Open the exercise file and edit the return statement with the JSX and save to see the magic happen!
1212

1313
<!--exercise-->
1414

15-
Although you write HTML looking syntax, your JSX code is compiled into a Javascript function like the one we saw in the previous page. The above JSX code is compiled into:
15+
Although you write HTML looking syntax, your JSX code is compiled into a JavaScript function like the one we saw in the previous page. The above JSX code is compiled into:
1616

1717
```jsx
1818
return React.createElement('div', null, 'Hello World');

0 commit comments

Comments
 (0)