Newer
Older
import React, { useRef, useState } from 'react';
import styled from 'styled-components';
const ExactAnswerContainer = styled.div`
display: flex;
flex-direction: row;
width: 100%;
`;
const ValueContainer = styled.div`
display: flex;
flex-direction: column;
margin-right: 25px;
label {
font-size: 12px;
}
input:focus {
outline: none;
}
`;
const ValueInnerContainer = styled.div`
display: flex;
flex-direction: column;
`;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const [minValue, setMinValue] = useState('');
const [maxValue, setMaxValue] = useState('');
const minRef = useRef(null);
const maxRef = useRef(null);
const onChangeMin = () => {
setMinValue(minRef.current.value);
};
const onChangeMax = () => {
setMaxValue(maxRef.current.value);
};
return (
<ExactAnswerContainer>
<ValueContainer>
<label htmlFor="minAnswer">
<ValueInnerContainer>
<span>Min</span>
<input
name="minAnswer"
onChange={onChangeMin}
ref={minRef}
type="text"
value={minValue}
/>
</ValueInnerContainer>
</label>
</ValueContainer>
<ValueContainer>
<label htmlFor="maxAnswer">
<ValueInnerContainer>
<span>Max</span>
<input
name="maxAnswer"
onChange={onChangeMax}
ref={maxRef}
type="text"
value={maxValue}
/>
</ValueInnerContainer>
</label>
</ValueContainer>
</ExactAnswerContainer>
);