Skip to content

Instantly share code, notes, and snippets.

@eamonnboyle
eamonnboyle / package.json
Last active February 22, 2021 14:53
Waether App Tutorial - create-react-app Scripts Section
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
@eamonnboyle
eamonnboyle / index.tsx
Last active February 22, 2021 15:05
Weather App Tutorial - index.tsx
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
@eamonnboyle
eamonnboyle / App.tsx
Created February 22, 2021 14:57
Weather App Tutorial - Starter App Component
import React from 'react';
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
@eamonnboyle
eamonnboyle / index.tsx
Last active February 22, 2021 15:10
Weather App Tutorial - Capitalisation of Component Names
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
@eamonnboyle
eamonnboyle / App.tsx
Created February 22, 2021 15:10
Weather App Tutorial - Empty App Component
...
function App() {
return (
<div>
<h1>Weather App</h1>
</div>
);
}
...
@eamonnboyle
eamonnboyle / App.tsx
Created February 22, 2021 15:12
Weather App Tutorial - Skeleton UI
...
function App() {
return (
<div>
<h1>Weather App</h1>
<div>
<label>
Add Location <input type="text" value="Paris"/>
</label>
<button>Search</button>
@eamonnboyle
eamonnboyle / App.tsx
Created February 22, 2021 15:12
Weather App Tutorial - First State
import React, {useState} from 'react';
// ...
function App() {
const [locationSearch, setLocationSearch] = useState('Paris');
// ...
@eamonnboyle
eamonnboyle / App.tsx
Created February 22, 2021 15:14
Weather App Tutorial - Binding State to Input
<label>
Add Location <input type="text" value={locationSearch}/>
</label>
@eamonnboyle
eamonnboyle / App.tsx
Created February 22, 2021 15:15
Weather App Tutorial - Adding Change Handler
<input type="text" value={locationSearch}
onChange={e => setLocationSearch(e.target.value)}/>
@eamonnboyle
eamonnboyle / App.tsx
Created February 22, 2021 15:16
Weather App Tutorial - Adding More State
function App() {
const [locationSearch, setLocationSearch] = useState('Paris');
const [locations, setLocations] = useState(['Belfast', 'Dublin']);