ビュー
関数
useExecuteAction

useExecuteAction

useExecuteAction は、アクションをすぐに実行するためのフックです。アクションの識別子とパラメータを指定することで、アクションを実行できます。

基本的な使い方

const App = () => {
    ...
    const { data, loading, error } = useExecuteAction("action-id", {
        company_name: '株式会社ベースマキナ',
        user_id: 123,
        checked: true,
        created: '2023-01-01',
    })
 
    return (
        {loading && <LoadingIndicator />}
        {data && <Table rows={data.results[0].success ?? []}/>}
    )
}

詳細なインターフェース

引数

識別子説明
actionId文字列実行するアクションのID。アクションは、アプリケーションの特定の機能を実行するための識別子です。c3hc2ii23akg0sokf9j0
argsオブジェクトアクションを実行するための引数で、 キーがパラメータ名、値がパラメータに渡す値のオブジェクトです。{ username: 'JohnDoe' }

なおパラメータの入力値の種類ごとにargsのプロパティの値に渡せる値の型は以下です。

入力値の種類説明
テキストstring-{ company_name: '株式会社ベースマキナ' }
数値number-{ user_id: 123 }
日付Date | string | numberstringDate型に変換できる値、numberはUnixTimestamp (秒)を入力してください。{ created: '2023-01-01', updated: new Date(), deleted: 1609459200 }
ファイルFile-{ upload_text: new File(['test'], 'test.txt', { type: 'text/plain' }) }
真偽値boolean-{ checked: true }
JSON値string | number | Date | nullJSON値の種類ごとに型が異なります。
テキストならstring | null、数値ならnumber | null、日付ならstring | number | Date | nullを渡せます。
日付の場合stringDate型に変換できる値、numberはUnixTimestamp (秒)を入力してください。 
{ company_name: '株式会社ベースマキナ', user_id: 123, created: '2023-01-01', deleted: null }
SQLstring-{ query: 'SELECT * FROM users;' }
システム値string-{ offset: '20' }
配列Array各要素の種類の型は、各入力値の種類の型と同じです。{ user_ids: [10, 11, 12] }

戻り値

プロパティ名説明
loadingbooleanアクションが現在実行中かどうかを示すブール値。true
dataオブジェクトアクションの実行結果。このオブジェクトはresultsという名前の配列を持っておりsuccessfailure のプロパティが含まれます。{"results":[{"success":[{"id":1,"name":"山田太郎"}]}]}
errorオブジェクトアクションの実行中に発生したエラー。-