Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
the task of the new clicker should be with the sum of all the previous ones

There is a task! It is necessary to create a new clicker by clicking on the button, which will be created with a value equal to the sum of all previous clickers (if there are clickers with a value of 3 and 5, the next one should be created with a value of 8). At the moment, I'm stuck on the problem that when creating a new clicker, the value of the previous one is stored in the volume. Tell me how to solve the problem? (Yes, and according to the condition, every fourth component should not be a clicker, but a timer)

function App() {
  const [click, setClick] = useState([]);

  function addClicker() {
    setClick([...click, <Counter />]);
  }

  function del() {
    setClick([...click.slice(0, click.length - 1)]);
  }

  return (
    <div className='app'>
      <AddDelButton />
      <button className='btn'  onClick={addClicker}>addClicker</button>
      <button className='btn' onClick={del}>delClicker</button>
      {click.map((item, i) =>
        !((i + 1) % 4) ? <NoClicker key={i} /> : <Counter props={click} key={i} />
      )}
    </div>
  );
}

////

function Counter(props) {
  const State = useSelector((state) => state.ourState.count);
  const dispatch = useDispatch();
  console.log('====>>>', State);


  return (
    <div className='counter'>
      <button className='btnClick'
        onClick={() => dispatch(incrementValue())}
      >
        Increment
      </button>
      <h2>{State}</h2>
      <button className='btnClick'
        onClick={() => dispatch(decrementValue())}
      >
        Decrement
      </button>
      <button>Delete</button>
    </div>
  );
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!