T
T
testtoster2020-01-31 09:17:26
JavaScript
testtoster, 2020-01-31 09:17:26

How to make automatic block color change?

There is a div block that has colors inline.

<div style={{ backgroundColor: 'green', height: '500px', width: '100%' }}></div>


How to make it so that each time the page is loaded, this block has a new color? As I understand it, in state you need to create a set of colors
this.state = {
      colors: ['#000', '#444', '#f2f2f2'],
    }


How now to connect the colors to the div block? Am I doing the right thing at all? Thanks everyone for the replies :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-01-31
@testtoster

Somehow , probably.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question