Skip to content

Instantly share code, notes, and snippets.

@zulnabil
Created June 28, 2019 12:42
Show Gist options
  • Select an option

  • Save zulnabil/0c077cd0dc1c0a64a3dfa6b899e7942d to your computer and use it in GitHub Desktop.

Select an option

Save zulnabil/0c077cd0dc1c0a64a3dfa6b899e7942d to your computer and use it in GitHub Desktop.
Component InputTeam
import React from 'react'
import styled from 'styled-components'
const PanelInputTeam = styled.div`
width: 400px;
margin: auto;
display: ${props => props.ready ? 'none' : 'flex'}
flex-direction: column;
justify-content: space-around;
`
function InputTeam(props) {
const teamA = React.useRef()
const teamB = React.useRef()
const handleSubmit = () => {
props.setTeams(
props.teams.concat(teamA.current.value, teamB.current.value)
)
props.setReady(true)
}
return (
<PanelInputTeam ready={props.ready}>
<h3>Input your team</h3>
<input ref={teamA} type='text' placeholder='Team A' />
<input ref={teamB} type='text' placeholder='Team B' />
<button onClick={handleSubmit}>Submit</button>
</PanelInputTeam>
)
}
export default InputTeam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment