Create a new single-page application in React
- Make sure npm 5.2 or later is installed
- npx create-react-app finance-app
- cd finance-app
- npm start
You should now see a running React app at localhost:3000.
What is public/index.html, src/index.js, and src/App.js
- public/index.html is the 'SPA' that is run by the browser and has all html built by react injected into it.
- src/index.js tells react where to inject the code --> ReactDOM.render(, document.getElementById('root'));
- src/App.js is where developers actually start writing React code.
What's in App.js?
- import statements
- class/extends
- render function
- export default
Creating our first class
- Think about folder/file management
- export default class
- render function
Inside StockInput
- state/load
- async/await loader method - this is a Promise. It is bound to load property.
- render - TickerInput with onSearch and state parameters passed in
Inside TickerInput
- Build out the render function - html, button click handle, DisplayData section
- Handle submit - get the user input (ticker) and call the onSearch function passed in as a property
- What do we want to display?
Inside LoadData
- Create the loadDividends function
- encode the query param
- create the url
- Fetch/.then chaining
- export default loadDividends