score:6

Accepted answer

Short Answer :- Remove the curly braces from the setAlertRules statement , as it is leading to an inconsistency between the type of setAlertRules at the definition and its usage.

This is feature of ES6 known as Object literal Shorthand.

At the time of Defining the alertRules the type of setAlertRules is SetStateAction< Alert [ ] > . And you are trying to give it value of type {alertRules: any} , which is leading to the error .

The value passed to alertRules is an object with key alertRules and its value as the array of type Alert.

So ,remove the curly brace as it is converted to something this

 setAlertRules({ alertRules: alertRules  }); 
  // now {alertRules: any} this thing will make sense 

try this code for updation of alertRules .

// see no curly braces .
 setAlertRules( alertRules ); 

Related Query

More Query from same tag