-1

Code snippet

Here i created a form and from there i am trying to update the dummyData when i console.log the data it's shows the updated one and if change anything in my code which triggers components to re-render it displays the new data,but not on submission of noteForm it does not re render the noteBlock.

Anit
  • 11
  • 2

1 Answers1

-1

To update the state, you need to follow an immutable approach using callbacks. See React documentation here

Example from the documentation

import React, { useState } from 'react';

function Example() {
  // Declare a new state variable, which we'll call "count"
  const [count, setCount] = useState(0);

  return (
    <div>
      <p>You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>
        Click me
      </button>
    </div>
  );
}
Moath
  • 540
  • 2
  • 9