Answer the question
In order to leave comments, you need to log in
How to make style changes dynamic in react?
I need to make it so that, for example, the width property can be passed user input as a value, who can tell me how to do this?
Answer the question
In order to leave comments, you need to log in
const [ width, setWidth ] = useState(0);
const onChange = e => setWidth(e.target.value);
const styles = { width: `${width}px` };
<input value={width} onChange={onChange} />
<div style={styles}>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question