Answers for "set className with ref react"

0

set className with ref react

class Test extends Component {
    constructor(props){
        //codes
    }

    hide = () => {
        const span = this.refs.spanLoading;
        span.ClassName = "hidden";
    }

    render() {

        return (
            <span ref="spanLoading" id="test-id" className="">The Quick Brown Fox.</span>

            <button onClick={() => this.hide()}>Hide</button>
        );
    }
}

export default Test;
Posted by: Guest on September-27-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language