title: React useState hooks error: Argument of type 'xxx' is not assignable to parameter of type 'SetStateAction<xx>'
body: <p>I use react hooks to update, but notice error when setState.</p>
  
  <blockquote>
    <p>Argument of type '{ alertRules: any; }' is not assignable to parameter of type 'SetStateAction'.
      Object literal may only specify known properties, and 'alertRules' does not exist in type 'SetStateAction'.ts(2345)</p>
  </blockquote>
  
  <p>Here is my code.</p>
  
  <pre><code>import React, { useState, useEffect } from 'react';
  import { FieldArray } from 'redux-form';
  import { CoordinateSelect } from '~/fields';
  import lodash from 'lodash';
  import { connect } from 'react-redux';
  import { filterDispatchers } from '~/actions';
  import t from '~/locale';
  
  interface Props {
    getAlertRules(o: object): Promise&lt;any&gt;;
  }
  type Alert = {
    ...
  }
  
  const connector = connect(
    null,
    filterDispatchers('getAlertRules'),
  );
  
  const AlertRuleForm = (props: Props) =&gt; {
    const [alertRules, setAlertRules] = useState&lt;Alert[]&gt;([]);
    useEffect(() =&gt; {
      fetchData();
    }, []);
  
    const fetchData = async () =&gt; {
      const actionResult = await props.getAlertRules({ limit: -1 });
      const alertRules = lodash.get(actionResult, 'response.alertRules', []);
      setAlertRules({ alertRules });    //Error form here
    };
  
    const groupedRules = lodash.groupBy(alertRules, 'resourceType');
    const levelTypes = lodash.uniq(alertRules.map((alert: Alert) =&gt; alert.level));
    return (
      &lt;FieldArray
        name="alertRules"
        component={CoordinateSelect}
        label={t('å‘Šè­¦è§„åˆ™')}
        firstOptions={lodash.keys(groupedRules)}
        secondOptions={groupedRules}
        thirdOptions={levelTypes}
        required
      /&gt;
    );
  };
  export default connector(AlertRuleForm);
  
  </code></pre>
  
  <p>the error is when set state </p>
  
  <blockquote>
    <p>Argument of type '{ alertRules: any; }' is not assignable to parameter of type 'SetStateAction'.
      Object literal may only specify known properties, and 'alertRules' does not exist in type 'SetStateAction'.ts(2345)</p>
  </blockquote>