This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} /> | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | |
})()} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> |