Skip to content

Instantly share code, notes, and snippets.

@gonzalolarrosa
Created August 1, 2018 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gonzalolarrosa/f6d57d37d659e40e5f85440267c33199 to your computer and use it in GitHub Desktop.
Save gonzalolarrosa/f6d57d37d659e40e5f85440267c33199 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import { string, func } from 'prop-types';
import './child-component.css';
export default class ChildComponent extends Component {
static propTypes = {
label: string,
onSubmit: func.isRequired
};
static defaultProps = {
label: “I’m your son”
};
constructor (props) {
super(props);
};
onClick = () => (onSubmit(this.props.label));
render () {
const { onSubmit, label} = this.props;
return(
<div className="container">
<Button onClick={onClick()}>{label}</Button>
</div>
);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment