Skip to content

Instantly share code, notes, and snippets.

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@ross-u
ross-u / Description.js
Last active September 19, 2023 21:17
React - Pass the props - Exercise
// src/components/Description.js
// Import react
import React from 'react';
// Create a function component and set props as the argument
function Description (props) {
return (
<div>
@ross-u
ross-u / App.js
Last active November 30, 2020 23:38
React state - Questions and Exercise
// src/App.js
import React, { Component } from 'react';
import User from './components/User';
// App.js
class App extends Component {
state = {
userA: {
firstName: "Harper",
avatarUrl: "https://www.refreshmiami.com/wp-content/uploads/2018/07/55085_logo-ironhack.png"
@ross-u
ross-u / App.js
Last active December 28, 2022 17:21
React state - exercise solution
// src/App.js
import React, { Component } from 'react';
import User from './components/User';
import Navbar from './components/Navbar';
class App extends Component {
state = {
userA: {
firstName: "Harper",
@ross-u
ross-u / App.js
Last active February 26, 2020 16:09
React Lifecycle methods - I Mounting - constructor()
import React from 'react';
import './App.css';
import Clock from './components/Clock';
class App extends React.Component {
state = {
currentTime: 'N/A',
showClock: true
}
@ross-u
ross-u / Clock.js
Last active February 27, 2020 10:07
React Lifecycle methods - I Mounting - render()
...
class Clock extends React.Component {
constructor(props) {
super(props);
this.state = {
year: props.year,
};
console.log('IN CONSTRUCTOR');
}
@ross-u
ross-u / Clock.js
Last active February 27, 2020 11:00
React Lifecycle methods - I Mounting - componentDidMount()
// ...
class Clock extends React.Component {
constructor(props) {
// ...
console.log('IN CONSTRUCTOR');
};
// custom methods and lifecycle methods go after the `constructor`
@ross-u
ross-u / App.js
Last active February 26, 2020 16:46
React Lifecycle methods - II Updating - componentDidUpdate()
// ...
class App extends React.Component {
// ...
// ...
@ross-u
ross-u / Clock.js
Last active February 26, 2020 17:06
React Lifecycle methods - III Unmounting - componentWillUnmount()
import React from 'react';
class Clock extends React.Component {
constructor(props) {
super(props);
this.state = {
year: 2020,
timerId: null, // <-- CREATE NEW PROPERTY
timer: 0, // <-- CREATE NEW PROPERTY
@ross-u
ross-u / App.js
Last active October 19, 2022 10:16
React | Lifecycle Methods Exercise
// App.js
import React, { Component } from 'react';
import './App.css';
import Counter from './components/Counter'
class App extends Component {