Skip to content

Instantly share code, notes, and snippets.

@thomasdavis
Created January 25, 2020 01:48
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 thomasdavis/23ea6b6c27acb21da3165e07f9569003 to your computer and use it in GitHub Desktop.
Save thomasdavis/23ea6b6c27acb21da3165e07f9569003 to your computer and use it in GitHub Desktop.
import { Component } from "react";
import styled from "styled-components";
const Layout = styled.div`
background: red;
width: 200px;
height: 200px;
`;
const Input = styled.input`
padding: 15px;
width: 100px;
`;
const Heading = styled.h1``;
const SomeButton = styled.button``;
const ViewWord = props => {
const { word } = props;
return <Heading>{word}</Heading>;
};
export default class Connections extends Component {
state = {
word: ""
};
alertMe = () => {
alert(this.state.word);
};
onWordChange = ev => {
this.setState({
word: ev.target.value
});
};
render() {
const { word } = this.state;
return (
<Layout>
<Input value={word} onChange={this.onWordChange} />
<SomeButton onClick={this.alertMe}>Click me</SomeButton>
<ViewWord word={word} />
</Layout>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment