Created
June 28, 2019 12:42
-
-
Save zulnabil/0c077cd0dc1c0a64a3dfa6b899e7942d to your computer and use it in GitHub Desktop.
Component InputTeam
This file contains hidden or 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
| 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