T
T
tostera2020-12-31 00:12:42
React
tostera, 2020-12-31 00:12:42

Why doesn't the style change?

Why are the styles not applied to the Textarea from tab 2, but remain like the Textarea from tab 1?
5fecec3fd0a43719131660.png
5fecec502196a801078985.png
5fecec6240586292394676.png

const res = {
    first: 'текст1',
    second: "текст2"
};

const Textarea = ({ style = {}, ...props }) => {
    const input = useRef();
    return (
        <textarea style={{ height: "auto", ...style }} ref={input} rows={1} {...props} />
    );
}

<div>
    <div className={panel === 0 ? "selected" : ''} onClick={() => setPanel(0)}>0</div>
    <div className={panel === 1 ? "selected" : ''} onClick={() => setPanel(1)}>1</div>
    <div className={panel === 2 ? "selected" : ''} onClick={() => setPanel(2)}>2</div>
</div>
{panel === 0 ?
    <div>
        <Textarea style={{fontSize: '12pt'}} value={res.first} readOnly={true} />
    </div>
: panel === 1 ?
    <div></div>
: panel === 2 ?
    <div>
        <Textarea style={{fontSize: '10pt', fontSize: 'monospace'}} value={res.second} readOnly={true} />
    </div>
: null}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2020-12-31
@HistoryART

<textarea style={style} ref={input} rows={1} {...props} />

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question