Skip to content

Instantly share code, notes, and snippets.

View luisgserrano's full-sized avatar
🎯
Doing stuff

Luis Serrano luisgserrano

🎯
Doing stuff
View GitHub Profile
import Time from '../../Filters/time.es6.jsx';
import Price from '../../Filters/price.es6.jsx';
import withDropdown from './withDropdown.es6.jsx';
import SmallerDropdown from './dropdown.es6.jsx';
const Dropdown = withDropdown(SmallerDropdown);
class ExampleComponent extends React.Component {
constructor(props) {
super(props);
const Dropdown = (props) => {
const childrenWithProps = React.cloneElement(props.children, { onSelect: props.clickHandler, ...props.children.props });
return (
<div className="filter filter--simple">
<div className="form-control" onClick={props.onToggle}>
<label>{props.label}</label>
<p>{props.value}</p>
</div>
{Optional(props.showDropdown).map((index) =>
const withDropdown = (WrappedComponent) =>
class extends React.Component {
constructor(props) {
super(props);
this.state = { showDropdown: false };
}
onToggle = () => this.setState({ 'showDropdown': !this.state.showDropdown });
@luisgserrano
luisgserrano / withDropdown.jsx
Last active February 23, 2018 20:44
Simple HOC - Medium article
const withDropdown = (WrappedComponent) =>
class extends React.Component {
constructor(props) {
super(props);
}
render() {
return <WrappedComponent {...this.props} />
}
};
@luisgserrano
luisgserrano / index.html
Created August 10, 2012 23:39
A web page created at CodePen.io.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- IF PEN IS PRIVATE -->
<!-- <meta name="robots" content="noindex"> -->
<!-- END -->