S
S
sharkdest2019-01-17 16:51:42
css
sharkdest, 2019-01-17 16:51:42

How to overwrite state in React?

How can I change the value of active ?

this.state = {
  clientData: {
    vatExisting: false,
    vatAmount: "",
    active: null
  }
};


I'm trying to do it this way, but I'm overwriting the clientData array and I only want clientData.active :
activeCheckboxChange = () => {
    this.setState(prevState => ({
      clientData: {active: !prevState.clientData.active }
    }));
  };

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Mr Crabbz, 2016-05-04
@CrewCut

overlay left and right translucent white blocks with absolute positioning.

M
Maxim Timofeev, 2016-05-04
@webinar

We take any js slider that can rotate several images, using css we modify the blocks with buttons, adding volume, transparency, and anything else.
Finishing js to taste

S
Sergey Tutukov, 2016-05-04
@sftutukov

as I understand it, your slider is in .container, and not in container-fluid Slider
wrappers

.slider{
  position:relative;
}

.slider:before,.slider:after{
  content:'';
  display: block;
  position:absolute;
  top:0;
  bottom:0;
  width: 100%; /*Вот тут проблема, чтобы точно определить расстояние от края до контейнера слайдера*/
  width:calc((100vw - 1000px)/2);  /*Смотрите кроссбраузерность*/
  background:rgba(255,255,255,.8);
}
.slider:before{
  right:100%;
}
.sliderr:after{
  left:100%;
}

codepen.io/STutukov/pen/mPardX
calc
if calc is not suitable, then you also need an oveflow wrapper so that it hides everything outside the screen. Briefly understand)))

0
0xD34F, 2019-01-17
@sharkdest

this.setState(prevState => ({
  clientData: {
    ...prevState.clientData,
    active: !prevState.clientData.active,
  },
}));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question