R
R
rsoinvi2018-07-01 16:59:09
React
rsoinvi, 2018-07-01 16:59:09

How to change block style at certain values?

I want to change the color of the block at certain values ​​from the repository
For example:
If the value is 20 then I make the block orange, if 50 then blue

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-07-01
@rsoinvi

The implementation depends on what style tools you use. The principle itself will be the same:

const getColor = value => {
  switch(value) {
    case 20:
      return 'orange';
    case 50:
      return 'blue';
  }
}

render() {
  const { value } = this.props;
  return <ExampleComponent style={{ color: getColor(value) }} />;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question