Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 597 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
561 geraldo 1
import React, { useState, useEffect } from "react";
2
 
3
const Option = (props) => {
4
 
5
    // get props
565 geraldo 6
    const { option } = props;
561 geraldo 7
 
8
    // init States
564 geraldo 9
    const [input, setInput] = useState(option.answer);
561 geraldo 10
 
11
    /**
564 geraldo 12
     * Update option answer
13
     * @param {*} value
561 geraldo 14
     */
15
    const handleAnswer = (value) => {
16
        setInput(value);
564 geraldo 17
        option.answer = value;
561 geraldo 18
    }
19
 
20
    /**
21
     * componentDidMount
22
     */
23
    useEffect(() => {
564 geraldo 24
        setInput(option.answer);
25
    }, [option]);
561 geraldo 26
 
27
 
564 geraldo 28
 
561 geraldo 29
    return (
597 geraldo 30
        <div className="col-md-12 col-sm-12 col-xs-12 np-padding mb10">
564 geraldo 31
            <div className="form-group" >
588 geraldo 32
                <div className="title">
598 geraldo 33
                    <h6 className="opt-h6">{option.title}:</h6>
597 geraldo 34
                </div>
564 geraldo 35
            </div>
588 geraldo 36
            <div className="form-group">
37
                <textarea
38
                    className="form-control"
39
                    rows="5"
40
                    value={input}
41
                    maxLength='200'
42
                    name={option.id_option}
43
                    onChange={e => handleAnswer(e.target.value)}
44
                />
45
            </div>
561 geraldo 46
        </div>
47
    )
48
}
49
 
566 geraldo 50
export default Option;