Skip to content

Instantly share code, notes, and snippets.

View Didericis's full-sized avatar

Eric Bauerfeld Didericis

View GitHub Profile
def get_cluster(cluster, point, traversed_points):
cluster.add(point)
traversed_points = traversed_points - {point}
untraversed_neighbors = point["neighbors"] - traversed_points
while untraversed_neighbors:
next_point = untraversed_neighbors.pop()
custer = get_cluster(cluster, next_point, traversed_points)
return cluster
class ListComponent extends Component {
// need to make sure to define instance method (not prototype) if you need to access state
sort = () => {
console.log('Sort');
}
render() {
return (
<ListComponentHeader sort={this.sort} />
);
}
class Fun extends Component {
render() {
return (
<div>
<h1>Hi</h1>
{(() => {
if (this.props.one) return <span>Fun</span>
if (this.props.two || this.props.three) return <h1>Stuff</h1>;
return <p>WEEEEE</p>
})()}
@Didericis
Didericis / example.jsx
Last active April 26, 2018 17:29
Passing props examples
// This architecture is fine if you normally pass around an object with the structure of
// bigObj. EX: If you have a BigObj type that always has firstName, lastName, address, state, etc,
class Component1 extends Component {
fullName = () => `${this.props.bigObj.firstName} ${this.props.bigObj.lastName}`;
location = () => `${this.props.bigObj.address} ${this.props.bigObj.state}`;
render() {
return (
<div>
<span>{this.fullName()}</span>
<span>{this.location()}</span>