set classname with ref react

Solutions on MaxInterview for set classname with ref react by the best coders in the world

showing results for - "set classname with ref react"
Ben
21 May 2020
1class Test extends Component {
2    constructor(props){
3        //codes
4    }
5
6    hide = () => {
7        const span = this.refs.spanLoading;
8        span.ClassName = "hidden";
9    }
10
11    render() {
12
13        return (
14            <span ref="spanLoading" id="test-id" className="">The Quick Brown Fox.</span>
15
16            <button onClick={() => this.hide()}>Hide</button>
17        );
18    }
19}
20
21export default Test;
22