|
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) |
0 commit comments