Skip to content

Instantly share code, notes, and snippets.

View ohansemmanuel's full-sized avatar

Ohans Emmanuel ohansemmanuel

View GitHub Profile
// An example of an action
const action = {
type: "WITHDRAW_MONEY",
amount: "$10,000"
}
// A basic reducer. Takes in two parameters: state, and action.
const reducer = (state, action) => {
return state;
};
...
const Description = ({ description }) => {
return (
<p>
<span className="faint">I am</span> a {description}
</p>
);
}
...
const Description = ({ description }) => {
return (
<p>
<I />
<Am />
<A />
<Profession profession={description} />
</p>
);
};
import React, {Component, PureComponent} from "react"
//before
class I extends Component {
render() {
return <span className="faint">I </span>;
}
//after
class I extends PureComponent {
const Description = ({ description }) => {
return (
<p>
<I />
<Am />
<A />
<Profession profession={description} />
</p>
);
};
const i = {
value: "i"
};
class I extends PureComponent {
render() {
return <span className="faint">{this.props.i.value} </span>;
}
}
class Description extends Component {
render() {
const i = {
value: "i"
};
return (
<p>
<I i={i} />
<Am />
<A />
...
render() {
<div onClick={() => {//do something here}}
}
...
...
handleClick:() ={
}
render() {
<div onClick={this.handleClick}
}
...