When I try to change colour depends on the count it show’s the error TypeError: Cannot read property ‘style’ of null

You can achieve what you wanted this way.

    <div className='container_new'>
        <span id='value' style={{ color: Count === 0 ? 'black' : 'white' }}>{Count}</span>
            <button className="btn decrease"  onClick={handleDecrement} >decrease</button>
            <button className="btn reset" style={{color: 'black'}} onClick={() => handleReset()}>reset</button>
            <button className="btn increase" onClick={() => handleIncrement()}>increase</button>

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top