Skip to content

Commit 9ed001d

Browse files
author
blazeka
committed
review of Idea Journal, move README to upper folder
1 parent aabf1c5 commit 9ed001d

File tree

16 files changed

+97
-87
lines changed

16 files changed

+97
-87
lines changed

lesson-2/README.md

Lines changed: 79 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,79 @@
1-
# Lesson - React Fundamentals I
2-
3-
- Creating an app with multiple components
4-
- Introduction to `props` and `state`
5-
- How components comunicate to each other
6-
- Deep dive to `this` and `bind`
7-
- So you don't have to have nightmares about it
8-
- What is Webpack and why it should be your best friend?
9-
- How your code happen to run in browser
1+
# React Fundamentals I
2+
3+
This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).
4+
5+
## The Goal
6+
7+
Finish all of bellow mentioned steps to manage Idea Journal store ideas in local state of the app.
8+
9+
## Practise & learn
10+
11+
_Exercise #1:_
12+
Clone it on your machine and then in project directory install npm modules and dependencies, run app in the development mode.
13+
14+
```
15+
npm i
16+
npm start
17+
```
18+
19+
### React Components
20+
- Components are like JavaScript functions - they accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen
21+
- Class and Functional components
22+
- Always start component names with a capital letter
23+
- Components must return a single root element
24+
25+
### React JSX
26+
- What UI should look like, it's neither string nor HTML
27+
- JavaScript expressions are wrapped into {}
28+
- Specifying attributes are string literals or {JavaScript expressions}
29+
- camelCase property naming, e.g. className, tabIndex
30+
31+
_Exercise (basics) #2:_
32+
Create Note component displaying title and text of a note.
33+
34+
_Exercise (basics) #3:_
35+
Create Footer component containing `<div>` with style class `Footer` and add it to App component.
36+
37+
### React State
38+
- State is similar to props, but it is private and fully controlled by the component
39+
- Class Components
40+
- Initial this.state is assigned in class constructor
41+
- Do not modify state directly, use setState()
42+
43+
_Exercise (state) #4:_
44+
Display modal window to add a new note.
45+
46+
_Exercise (state) #5:_
47+
Display or hide text in Note component.
48+
49+
### React Props
50+
- Props are attributes of component
51+
- Read-only - component never modify its own props
52+
53+
_Exercise (props) #6:_
54+
Pass notes info via props from App to NoteList.
55+
56+
_Exercise (props) #6:_
57+
Pass note info via props from NoteList to Note.
58+
59+
_Exercise (props) #7:_
60+
Pass callback function from NewNoteModal to App and add a new note to a list.
61+
62+
_EXTRA Exercise (props) #7:_
63+
Pass callback function from Note to App and remove note from a list.
64+
65+
To run solution
66+
```
67+
cd solution/
68+
npm i
69+
npm start # or PORT=3001 npm start to run in parallel with working app
70+
```
71+
72+
## Useful resources
73+
74+
- [React.js - Introducing JSX](https://facebook.github.io/react/docs/introducing-jsx.html)
75+
- [React.js - Rendering Elements](https://facebook.github.io/react/docs/rendering-elements.html)
76+
- [React.js - Components and props](https://facebook.github.io/react/docs/components-and-props.html)
77+
- [React.js - State and lifecycle](https://reactjs.org/docs/state-and-lifecycle.html)
78+
- [React Patterns](http://reactpatterns.com/)
79+
- [The many faces of `this` in javascript](https://blog.pragmatists.com/the-many-faces-of-this-in-javascript-5f8be40df52e)

lesson-2/idea-journal/README.md

Lines changed: 0 additions & 54 deletions
This file was deleted.

lesson-2/idea-journal/solution/src/components/App.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ class App extends React.Component {
1818

1919
addNoteToList = (note) => {
2020
const {notes} = this.state
21-
const newNote = {...note}
2221
this.setState({
23-
notes: notes.concat(newNote)
22+
notes: notes.concat(note)
2423
})
2524
}
2625

lesson-2/idea-journal/solution/src/components/Footer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ class Footer extends React.Component {
1111
}
1212
}
1313

14-
export default Footer
14+
export default Footer

lesson-2/idea-journal/solution/src/components/Header.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ class Header extends React.Component {
1919
}
2020
}
2121

22-
export default Header
22+
export default Header

lesson-2/idea-journal/solution/src/components/NewNoteModal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ class NewNoteModal extends React.Component {
6060
}
6161
}
6262

63-
export default NewNoteModal
63+
export default NewNoteModal

lesson-2/idea-journal/solution/src/components/Note.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ class Note extends React.Component {
3232
}
3333
}
3434

35-
export default Note
35+
export default Note

lesson-2/idea-journal/solution/src/components/NoteList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ class NoteList extends React.Component {
1616
}
1717
}
1818

19-
export default NoteList
19+
export default NoteList

lesson-2/idea-journal/solution/src/styles/Footer.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
width:100%;
77
background-color: #ede0b0;
88
box-shadow: 0 0px 8px #000000;
9-
}
9+
}

lesson-2/idea-journal/solution/src/styles/NoteList.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
display: flex;
33
flex-direction: column;
44
align-items: center;
5-
}
5+
}

0 commit comments

Comments
 (0)