{"id":11085,"date":"2022-10-10T07:00:38","date_gmt":"2022-10-09T22:00:38","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=11085"},"modified":"2022-10-06T17:04:20","modified_gmt":"2022-10-06T08:04:20","slug":"laravel-precognition-%e3%81%a7%e3%83%aa%e3%82%a2%e3%83%ab%e3%82%bf%e3%82%a4%e3%83%a0%e3%83%bb%e3%83%90%e3%83%aa%e3%83%87%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e3%81%a4%e3%81%8f%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=11085","title":{"rendered":"Laravel Precognition \u3067\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u30fb\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u3064\u304f\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u300c<strong>\u3055\u3059\u304c\u306b\u3082\u3046Laravel\u306e\u9032\u5316\u306f\u6b62\u307e\u308b\u3067\u3057\u3087<\/strong>\u300d\u3068\u4f55\u5ea6\u304b\u8003\u3048\u305f\u3053\u3068\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u7686\u3055\u3093\u3082\u3054\u5b58\u77e5\u306e\u901a\u308a\u307e\u3060\u307e\u3060\u9032\u5316\u306f\u6b62\u307e\u308b\u3053\u3068\u306f\u306a\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u306e\u3082\u3001\u3053\u306e\u524d\u30c4\u30a4\u30c3\u30bf\u30fc\u3067\u3044\u3064\u3082\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u3044\u305f\u3060\u3044\u3066\u3044\u308b <a href=\"https:\/\/twitter.com\/shiro_cake\" target=\"_blank\" rel=\"noopener\">shirocake<\/a> \u3055\u3093\u304c\u300c<strong>Laravel Precognition \u306a\u308b\u65b0\u6a5f\u80fd\u304c\u5b9f\u88c5\u3055\u308c\u305f<\/strong>\u300d\u3068\u3044\u3046 <a href=\"https:\/\/twitter.com\/shiro_cake\/status\/1575714553135976449\" target=\"_blank\" rel=\"noopener\">\u30c4\u30a4\u30fc\u30c8<\/a> \u3092\u6295\u7a3f\u3055\u308c\u3001\u3053\u308c\u304c\u306a\u304b\u306a\u304b\u9762\u767d\u305d\u3046\u3060\u3063\u305f\u3093\u304b\u3089\u306a\u3093\u3067\u3059\u306d\u3002\uff08\u3044\u3064\u3082\u60c5\u5831\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\u2757\uff09<\/p>\n<p><code>GitHub<\/code>\u306e\u30d7\u30eb\u30ea\u30af\u30a8\u30b9\u30c8\u306f <a href=\"https:\/\/github.com\/laravel\/framework\/pull\/44339\" target=\"_blank\" rel=\"noopener\">\u3053\u3061\u3089<\/a>\u3002<\/p>\n<p>\u3053\u306e<code>Precognition<\/code>\u3068\u3044\u3046\u540d\u524d\u306f\u300c<strong>\u4e8b\u524d\u306b<\/strong>\u300d\u300c<strong>\u8a8d\u77e5\u3059\u308b<\/strong>\u300d\u3068\u306e\u3053\u3068\u3067\u3001\u3056\u3063\u304f\u308a\u8a00\u3046\u3068\u300c<strong>\u30c7\u30fc\u30bf\u9001\u4fe1\u3059\u308b\u524d\u306b\u3001\u4e8b\u524d\u306b\u4f55\u304b\u3092\u3059\u308b<\/strong>\u300d\u3068\u3044\u3046\u3082\u306e\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u3059\u308b\u5834\u5408\u306b\u30a2\u30ab\u30a6\u30f3\u30c8\u540d\u300c<strong>sukohi<\/strong>\u300d\u304c\u3082\u3046\u53d6\u5f97\u6e08\u307f\u304b\u3069\u3046\u304b\u306f\u3001\u30c7\u30fc\u30bf\u9001\u4fe1\u6642\u3058\u3083\u306a\u304f\u3066\u5165\u529b\u306e\u76f4\u5f8c\u306b\u300c\u3082\u3046\u53d6\u3089\u308c\u3061\u3083\u3063\u3066\u308b\u3088\u2757\u300d\u3068\u6559\u3048\u3066\u307b\u3057\u3044\u3067\u3059\u3088\u306d\u3002\uff08\u3064\u307e\u308a\u3001\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u30fb\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\uff09<\/p>\n<p>\u3053\u308c\u304c\u5b9f\u73fe\u3067\u304d\u308b\u306e\u304c<code>Laravel Precognition<\/code>\u3067\u3059\u3002<\/p>\n<p>\u203b <code>Precognition<\/code>\u306f\u30d8\u30c3\u30c0\u30fc\u306b\u30c7\u30fc\u30bf\u3092\u30bb\u30c3\u30c8\u3059\u308b\u3053\u3068\u3067\u8d77\u52d5\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u3067\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3060\u3051\u3067\u306a\u304f\u3001\u5171\u540c\u7de8\u96c6\u3057\u3066\u3044\u308b\u30da\u30fc\u30b8\u3067\u300c<strong>\u3044\u3084\u3044\u3084\u3001\u3053\u306e\u30da\u30fc\u30b8\u3001\u30ed\u30c3\u30af\u3055\u308c\u3066\u308b\u304b\u3089\u2757<\/strong>\u300d\u3068\u30a8\u30e9\u30fc\u8868\u793a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u4eca\u56de\u306f\u79c1\u3082<code>Precognition<\/code>\u521d\u5fc3\u8005\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4e00\u756a\u30b7\u30f3\u30d7\u30eb\u305d\u3046\u306a\u300c<strong>\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u30fb\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong>\u300d\u3092\u300c<strong>Laravel + React<\/strong>\u300d\u3067\u5b9f\u88c5\u3057\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u305c\u3072\u4f55\u304b\u306e\u53c2\u8003\u306b\u306a\u308a\u307e\u3057\u305f\u3089\u5b09\u3057\u3044\u3067\u3059\ud83d\ude04\u2728<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3566 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_1.png\" alt=\"\" width=\"306\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_1.png 306w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_1-287x300.png 287w\" sizes=\"auto, (max-width: 306px) 100vw, 306px\" \/>\u300c\u30a6\u30c1\u306e\u59ea\u3063\u5b50\u304c<br \/>\n\u3068\u3042\u308b\u7af6\u6280\u306e<br \/>\n\u30d7\u30ed\u30e9\u30a4\u30bb\u30f3\u30b9\u53d6\u308a\u307e\u3057\u305f\ud83c\udf89\u2728\u300d<\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Laravel 9.34.0\u3001React\u3001Inertia.js\u3001Vite\u3001TailwindCSS<\/p>\n<h1>Laravel Precognition \u3092\u4f7f\u3048\u308b\u3088\u3046\u306b\u3059\u308b<\/h1>\n<p><code>Laravel Precognition<\/code>\u306f\u3001\u5b9f\u969b\u306b\u306f\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u306f\u306a\u304f<code>2022.09.29<\/code>\u306b<code>Laravel 9.x<\/code>\u3078\u8ffd\u52a0\u3055\u308c\u305f\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u3082\u3057\u305d\u308c\u3088\u308a\u524d\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u5834\u5408\u306f<code>Laravel Precognition<\/code>\u306f\u4f7f\u3048\u307e\u305b\u3093\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067<code>Laravel<\/code>\u672c\u4f53\u3092\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>composer update<\/strong><\/pre>\n<p>\u3067\u306f\u3001\u697d\u3057\u3093\u3067\u4f5c\u696d\u3092\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u2757<\/p>\n<h1>\u30eb\u30fc\u30c8\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u307e\u305a\u306f\u30eb\u30fc\u30c8\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u4f7f\u3046\u306e\u306f\u4ee5\u4e0b\u306e\uff12\u3064\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u9001\u4fe1\u30d5\u30a9\u30fc\u30e0<\/li>\n<li>\u9001\u4fe1\u5148<\/li>\n<\/ul>\n<p><strong>routes\/web.php<\/strong><\/p>\n<pre><strong>use App\\Http\\Controllers\\PrecognitionFormController;<\/strong>\r\n<strong>use Illuminate\\Foundation\\Http\\Middleware\\HandlePrecognitiveRequests;<\/strong>\r\n\r\n\/\/ \u7701\u7565\r\n\r\n<strong>Route::prefix('precognition_form')-&gt;controller(PrecognitionFormController::class)-&gt;group(function(){<\/strong>\r\n\r\n<strong>    Route::get('\/create', 'create')<\/strong>\r\n<strong>        -&gt;name('precognition_form.create');<\/strong>\r\n<strong>    Route::post('\/', 'store')<\/strong>\r\n<strong>        -&gt;middleware([HandlePrecognitiveRequests::class])<\/strong>\r\n<strong>        -&gt;name('precognition_form.store');<\/strong>\r\n\r\n<strong>});<\/strong><\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u91cd\u8981\u306a\u306e\u304c\u3001<code>HandlePrecognitiveRequests<\/code>\u3092\u4f7f\u3063\u3066\u3044\u308b\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p>\u5b9f\u306f\u3053\u306e\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u3092\u30bb\u30c3\u30c8\u3059\u308b\u3060\u3051\u3067<code>Precognition<\/code>\u304c\u6709\u52b9\u306b\u306a\u308a\u307e\u3059\u3002\uff08\u3064\u307e\u308a\u3001\u4eca\u56de\u306f<code>store()<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u307f\u3067\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff09<\/p>\n<h1>Form Request\uff08\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u90e8\u5206\uff09\u3092\u3064\u304f\u308b<\/h1>\n<p>\u6b21\u306b\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u90e8\u5206\u3092\u3064\u304f\u3063\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan make:request PrecognitionFormRequest<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p><strong>app\/Http\/Requests\/PrecognitionFormRequest.php<\/strong><\/p>\n<pre>&lt;?php\r\n\r\nnamespace App\\Http\\Requests;\r\n\r\nuse Illuminate\\Foundation\\Http\\FormRequest;\r\n<strong>use Illuminate\\Validation\\Rules\\Password;<\/strong>\r\n\r\nclass PrecognitionFormRequest extends FormRequest\r\n{\r\n    \/**\r\n     * Determine if the user is authorized to make this request.\r\n     *\r\n     * @return bool\r\n     *\/\r\n    public function authorize()\r\n    {\r\n        <strong>return true;<\/strong>\r\n    }\r\n\r\n    \/**\r\n     * Get the validation rules that apply to the request.\r\n     *\r\n     * @return array&lt;string, mixed&gt;\r\n     *\/\r\n    public function rules()\r\n    {\r\n        <strong>return [<\/strong>\r\n<strong>            'name' =&gt; 'required|min:5',<\/strong>\r\n<strong>            'email' =&gt; 'required|email',<\/strong>\r\n<strong>            'password' =&gt; [ \/\/ \u4f8b\uff1a StrongPassword^0^<\/strong>\r\n<strong>                'required',<\/strong>\r\n<strong>                Password::min(16)   \/\/ 16\u6587\u5b57\u4ee5\u4e0a<\/strong>\r\n<strong>                    -&gt;letters()     \/\/ \u6587\u5b57\u304c\u542b\u307e\u308c\u3066\u3044\u308b<\/strong>\r\n<strong>                    -&gt;mixedCase()   \/\/ \u5927\u6587\u5b57\uff06\u5c0f\u6587\u5b57\u304c\u542b\u307e\u308c\u3066\u3044\u308b<\/strong>\r\n<strong>                    -&gt;numbers()     \/\/ \u6570\u5b57\u304c\u542b\u307e\u308c\u3066\u3044\u308b<\/strong>\r\n<strong>                    -&gt;symbols()     \/\/ \u7279\u6b8a\u6587\u5b57\u304c\u542b\u307e\u308c\u3066\u3044\u308b<\/strong>\r\n<strong>            ],<\/strong>\r\n<strong>        ];<\/strong>\r\n    }\r\n}<\/pre>\n<p>\u3061\u306a\u307f\u306b\u3001<code>Precognition<\/code>\u3068\u306f\u95a2\u4fc2\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u5f37\u5ea6\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u305f\u3081\u4ee5\u4e0b\u306e\u3082\u306e\u3092\u542b\u3081\u3066\u3044\u307e\u3059\u3002\u5408\u308f\u305b\u3066\u899a\u3048\u3066\u304a\u304f\u3068\u4fbf\u5229\u3067\u3059\u3088\ud83d\udc4d<\/p>\n<ul>\n<li>min\uff1a \uff0a\u6587\u5b57\u4ee5\u4e0a\u3067\u306a\u3044\u3068\u30c0\u30e1\u2757<\/li>\n<li>letters\uff1a \u6587\u5b57\u542b\u307e\u308c\u3066\u306a\u3044\u3068\u30c0\u30e1\u2757<\/li>\n<li>mixedCase\uff1a \uff08\u30a2\u30eb\u30d5\u30a1\u30d9\u30c3\u30c8\u306e\uff09\u5927\u6587\u5b57\uff06\u5c0f\u6587\u5b57\u304c\u542b\u307e\u308c\u3066\u306a\u3044\u3068\u30c0\u30e1\u2757<\/li>\n<li>numbers\uff1a \u6570\u5b57\u304c\u542b\u307e\u308c\u3066\u306a\u3044\u3068\u30c0\u30e1\u2757<\/li>\n<li>symbols\uff1a \u7279\u6b8a\u6587\u5b57\uff08\u300c$^\u300d\u306a\u3069\uff09\u304c\u542b\u307e\u308c\u3066\u306a\u3044\u3068\u30c0\u30e1\u2757<\/li>\n<\/ul>\n<p><strong>\u30d1\u30b9\u30ef\u30fc\u30c9\u4f8b\uff1a <\/strong>StrongPassword^0^<\/p>\n<p>\u203b \u3061\u306a\u307f\u306b\u53cb\u4eba\u3044\u308f\u304f\u300c\u7279\u6b8a\u6587\u5b57\u5165\u308c\u308d\u30fc\u3068\u304b\u30a4\u30e9\u30a4\u30e9\u3059\u308b\u3088\u306d\ud83d\ude2b\u300d\u3068\u306e\u3053\u3068\u3067\u3059\u304c\u2026\uff08\u7b11\uff09<\/p>\n<p>\u307e\u305f\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u30c1\u30a7\u30c3\u30af\u3092\u4e00\u5143\u7ba1\u7406\u3057\u305f\u3044\u5834\u5408\u306f <a href=\"https:\/\/zenn.dev\/nshiro\/articles\/50a04a9e62cc2b\" target=\"_blank\" rel=\"noopener\">Password::defaults()<\/a> \u3082\u4fbf\u5229\u3067\u3059\u3088\ud83d\udc4d<\/p>\n<h1>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u308b<\/h1>\n<p>\u7d9a\u3044\u3066\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan make:controller PrecognitionFormController<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p><strong>app\/Http\/Controllers\/PrecognitionFormController.php<\/strong><\/p>\n<pre><strong>&lt;?php<\/strong>\r\n\r\n<strong>namespace App\\Http\\Controllers;<\/strong>\r\n\r\n<strong>use App\\Http\\Requests\\PrecognitionFormRequest;<\/strong>\r\n<strong>use Illuminate\\Http\\Request;<\/strong>\r\n<strong>use Inertia\\Inertia;<\/strong>\r\n\r\n<strong>class PrecognitionFormController extends Controller<\/strong>\r\n<strong>{<\/strong>\r\n<strong>    public function create()<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        return Inertia::render('PrecognitionForm\/Index');<\/strong>\r\n<strong>    }<\/strong>\r\n\r\n<strong>    public function store(PrecognitionFormRequest $request)<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        \/\/ \u3053\u3053\u3067\u4f55\u304b\u3092\u3059\u308b<\/strong>\r\n\r\n<strong>        return ['result' =&gt; true];<\/strong>\r\n<strong>    }<\/strong>\r\n<strong>}<\/strong><\/pre>\n<p><code>Inertia + React<\/code>\u306a\u306e\u3067\u3068\u3066\u3082\u30b7\u30f3\u30d7\u30eb\u3067\u3059\u304c\u3001<code>store()<\/code>\u306b\u5148\u307b\u3069\u306e<code>PrecognitionFormRequest<\/code>\u3092\u30bb\u30c3\u30c8\u3059\u308b\u306e\u3092\u5fd8\u308c\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002<\/p>\n<h1>\u30d3\u30e5\u30fc\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u6700\u5f8c\u306b<code>React<\/code>\u3092\u4f7f\u3046\u30d3\u30e5\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>resources\/js\/Pages\/PrecognitionForm\/Index.jsx<\/strong><\/p>\n<pre><strong>import {useEffect, useState} from 'react';<\/strong>\r\n<strong>import axios from 'axios';<\/strong>\r\n<strong>import _ from 'lodash';<\/strong>\r\n\r\n<strong>export default function Index() {<\/strong>\r\n\r\n<strong>    \/\/ \u30c7\u30fc\u30bf<\/strong>\r\n<strong>    const [params, setParams] = useState({<\/strong>\r\n<strong>        name: '',<\/strong>\r\n<strong>        email: '',<\/strong>\r\n<strong>        password: '',<\/strong>\r\n<strong>    });<\/strong>\r\n<strong>    const [precognitionKey, setPrecognitionKey] = useState('');<\/strong>\r\n\r\n<strong>    \/\/ \u30d5\u30a9\u30fc\u30e0\u5024<\/strong>\r\n<strong>    const handleInputChange = e =&gt; {<\/strong>\r\n\r\n<strong>        const key = e.target.name;<\/strong>\r\n<strong>        const value = e.target.value;<\/strong>\r\n\r\n<strong>        \/\/ \u90e8\u5206\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3059\u308b\u30ad\u30fc\u3092\u4fdd\u6301\uff08useEffect \u3067\u4f7f\u3046\uff09<\/strong>\r\n<strong>        setPrecognitionKey(key);<\/strong>\r\n\r\n<strong>        \/\/ \u65b0\u3057\u3044\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u30d1\u30e9\u30e1\u30fc\u30bf\u3078\u8ffd\u52a0<\/strong>\r\n<strong>        setParams({<\/strong>\r\n<strong>            ...params,<\/strong>\r\n<strong>            ...{[key]: value}<\/strong>\r\n<strong>        });<\/strong>\r\n\r\n<strong>    };<\/strong>\r\n<strong>    useEffect(() =&gt; {<\/strong>\r\n\r\n<strong>        if(precognitionKey !== '') {<\/strong>\r\n\r\n<strong>            handleSubmit(true); \/\/ Precognition \u3068\u3057\u3066\u9001\u4fe1\uff08\u90e8\u5206\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\uff09<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>    }, [params]);<\/strong>\r\n\r\n<strong>    \/\/ \u9001\u4fe1<\/strong>\r\n<strong>    const handleSubmit = (isPrecognition = false) =&gt; {<\/strong>\r\n\r\n<strong>        const url = route('precognition_form.store');<\/strong>\r\n<strong>        let config = getSubmitConfig(isPrecognition);<\/strong>\r\n\r\n<strong>        axios.post(url, params, config)<\/strong>\r\n<strong>            .then(onSubmitSuccess) \/\/ \u6210\u529f\u3057\u305f\u3068\u304d<\/strong>\r\n<strong>            .catch(onSubmitError); \/\/ \u5931\u6557\u3057\u305f\u3068\u304d<\/strong>\r\n\r\n<strong>    };<\/strong>\r\n<strong>    const getSubmitConfig = isPrecognition =&gt; {<\/strong>\r\n\r\n<strong>        if(isPrecognition === true) { \/\/ Precognition \u306e\u5834\u5408\u306f\u30d8\u30c3\u30c0\u30fc\u3092\u3064\u3051\u308b<\/strong>\r\n\r\n<strong>            return {<\/strong>\r\n<strong>                headers:{<\/strong>\r\n<strong>                    'Accept': 'application\/json',<\/strong>\r\n<strong>                    'Precognition': 'true',<\/strong>\r\n<strong>                    'Precognition-Validate-Only': precognitionKey,<\/strong>\r\n<strong>                }<\/strong>\r\n<strong>            };<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>        return {};<\/strong>\r\n\r\n<strong>    };<\/strong>\r\n<strong>    const onSubmitSuccess = response =&gt; {<\/strong>\r\n\r\n<strong>        const isPrecognition = (response.headers.precognition === 'true');<\/strong>\r\n\r\n<strong>        if(isPrecognition === true) { \/\/ Precognition \uff08\u90e8\u5206\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\uff09\u306e\u5834\u5408<\/strong>\r\n\r\n<strong>            const newResponseErrors = {<\/strong>\r\n<strong>                ...errors,<\/strong>\r\n<strong>                ...{[precognitionKey]: ''} \/\/ \u30a8\u30e9\u30fc\u3092\u524a\u9664<\/strong>\r\n<strong>            };<\/strong>\r\n\r\n<strong>            setErrors(newResponseErrors);<\/strong>\r\n\r\n<strong>        } else { \/\/ \u672c\u9001\u4fe1<\/strong>\r\n\r\n<strong>            alert('\u6210\u529f\uff01');<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n<strong>    const onSubmitError = error =&gt; {<\/strong>\r\n\r\n<strong>        let newResponseErrors = {};<\/strong>\r\n<strong>        const isPrecognition = (error.response.headers.precognition === 'true');<\/strong>\r\n\r\n<strong>        if(isPrecognition === true) {<\/strong>\r\n\r\n<strong>            const errorMessage = _.get(error, `response.data.errors.${precognitionKey}.0`, '');<\/strong>\r\n<strong>            newResponseErrors = { \/\/ \u65b0\u3057\u3044\u30a8\u30e9\u30fc\u3092\u8ffd\u52a0<\/strong>\r\n<strong>                ...errors,<\/strong>\r\n<strong>                ...{[precognitionKey]: errorMessage}<\/strong>\r\n<strong>            };<\/strong>\r\n\r\n<strong>        } else {<\/strong>\r\n\r\n<strong>            const keys = Object.keys(params);<\/strong>\r\n<strong>            keys.forEach(key =&gt; {<\/strong>\r\n\r\n<strong>                newResponseErrors[key] = _.get(error, `response.data.errors.${key}.0`, '');<\/strong>\r\n\r\n<strong>            });<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>        setErrors(newResponseErrors);<\/strong>\r\n\r\n<strong>    };<\/strong>\r\n\r\n<strong>    \/\/ \u30a8\u30e9\u30fc<\/strong>\r\n<strong>    let [errors, setErrors] = useState({});<\/strong>\r\n<strong>    useEffect(() =&gt; {<\/strong>\r\n\r\n<strong>        let responseErrors = {};<\/strong>\r\n<strong>        const errorKeys = Object.keys(params);<\/strong>\r\n\r\n<strong>        errorKeys.forEach(key =&gt; { \/\/ \u30a8\u30e9\u30fc\u30c7\u30fc\u30bf\u3092\u521d\u671f\u5316\uff08\u81ea\u52d5\u3067\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u5408\u308f\u305b\u308b\uff09<\/strong>\r\n\r\n<strong>            responseErrors[key] = '';<\/strong>\r\n\r\n<strong>        });<\/strong>\r\n\r\n<strong>    }, []);<\/strong>\r\n\r\n<strong>    return (<\/strong>\r\n<strong>        &lt;div className=\"p-5 bg-gray-200\"&gt;<\/strong>\r\n<strong>            &lt;h1 className=\"mb-4 text-center font-medium text-lg\"&gt;Laravel Precognition \u3067\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u30fb\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3&lt;\/h1&gt;<\/strong>\r\n<strong>            &lt;div className=\"flex justify-center\"&gt;<\/strong>\r\n<strong>                &lt;div className=\"w-full max-w-2xl\"&gt;<\/strong>\r\n<strong>                    &lt;div className=\"bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4\"&gt;<\/strong>\r\n<strong>                        &lt;div className=\"mb-4\"&gt;<\/strong>\r\n<strong>                            &lt;label className=\"block text-sm font-bold mb-2\"&gt;<\/strong>\r\n<strong>                                \u540d\u524d<\/strong>\r\n<strong>                            &lt;\/label&gt;<\/strong>\r\n<strong>                            &lt;input<\/strong>\r\n<strong>                                className=\"border rounded w-full py-2 px-3\"<\/strong>\r\n<strong>                                type=\"text\"<\/strong>\r\n<strong>                                name=\"name\"<\/strong>\r\n<strong>                                placeholder=\"\u540d\u524d\"<\/strong>\r\n<strong>                                value={params.name}<\/strong>\r\n<strong>                                onChange={handleInputChange}\/&gt;<\/strong>\r\n<strong>                            {errors.name &amp;&amp; (<\/strong>\r\n<strong>                                &lt;p className=\"text-red-500 text-xs italic\"&gt;{errors.name}&lt;\/p&gt;<\/strong>\r\n<strong>                            )}<\/strong>\r\n<strong>                        &lt;\/div&gt;<\/strong>\r\n<strong>                        &lt;div className=\"mb-4\"&gt;<\/strong>\r\n<strong>                            &lt;label className=\"block text-sm font-bold mb-2\"&gt;<\/strong>\r\n<strong>                                \u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9<\/strong>\r\n<strong>                            &lt;\/label&gt;<\/strong>\r\n<strong>                            &lt;input<\/strong>\r\n<strong>                                className=\"border rounded w-full py-2 px-3\"<\/strong>\r\n<strong>                                type=\"email\"<\/strong>\r\n<strong>                                name=\"email\"<\/strong>\r\n<strong>                                placeholder=\"\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\"<\/strong>\r\n<strong>                                value={params.email}<\/strong>\r\n<strong>                                onChange={handleInputChange}\/&gt;<\/strong>\r\n<strong>                            {errors.email &amp;&amp; (<\/strong>\r\n<strong>                                &lt;p className=\"text-red-500 text-xs italic\"&gt;{errors.email}&lt;\/p&gt;<\/strong>\r\n<strong>                            )}<\/strong>\r\n<strong>                        &lt;\/div&gt;<\/strong>\r\n<strong>                        &lt;div className=\"mb-4\"&gt;<\/strong>\r\n<strong>                            &lt;label className=\"block text-sm font-bold mb-2\"&gt;<\/strong>\r\n<strong>                                \u30d1\u30b9\u30ef\u30fc\u30c9<\/strong>\r\n<strong>                            &lt;\/label&gt;<\/strong>\r\n<strong>                            &lt;input<\/strong>\r\n<strong>                                className=\"border rounded w-full py-2 px-3\"<\/strong>\r\n<strong>                                type=\"password\"<\/strong>\r\n<strong>                                name=\"password\"<\/strong>\r\n<strong>                                placeholder=\"\u30d1\u30b9\u30ef\u30fc\u30c9\"<\/strong>\r\n<strong>                                value={params.password}<\/strong>\r\n<strong>                                onChange={handleInputChange}\/&gt;<\/strong>\r\n<strong>                            {errors.password &amp;&amp; (<\/strong>\r\n<strong>                                &lt;p className=\"text-red-500 text-xs italic\"&gt;{errors.password}&lt;\/p&gt;<\/strong>\r\n<strong>                            )}<\/strong>\r\n<strong>                        &lt;\/div&gt;<\/strong>\r\n<strong>                        &lt;div className=\"text-right\"&gt;<\/strong>\r\n<strong>                            &lt;button<\/strong>\r\n<strong>                                type=\"button\"<\/strong>\r\n<strong>                                className=\"px-4 py-2.5 text-sm font-medium text-center text-white bg-blue-700 rounded-lg\"<\/strong>\r\n<strong>                                onClick={handleSubmit}&gt;\u9001\u4fe1\u3059\u308b&lt;\/button&gt;<\/strong>\r\n<strong>                        &lt;\/div&gt;<\/strong>\r\n<strong>                    &lt;\/div&gt;<\/strong>\r\n<strong>                &lt;\/div&gt;<\/strong>\r\n<strong>            &lt;\/div&gt;<\/strong>\r\n<strong>        &lt;\/div&gt;<\/strong>\r\n<strong>    );<\/strong>\r\n\r\n<strong>}<\/strong><\/pre>\n<p>\u5c11\u3057\u30b3\u30fc\u30c9\u304c\u9577\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u304c\u3001\u5c11\u3057\u305a\u3064\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<h2>\u5c02\u7528\u30d1\u30c3\u30b1\u30fc\u30b8\u306b\u3064\u3044\u3066<\/h2>\n<p><code>Precognition<\/code>\u306e\u8aac\u660e\u6587\u306b\u306f\u300c<strong>\u5c02\u7528 JavaScript \u5411\u3051\u30d1\u30c3\u30b1\u30fc\u30b8<\/strong>\u300d\u306b\u3064\u3044\u3066\u8a00\u53ca\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u3001\uff08\u904e\u53bb\u306b\u306f<code>npm<\/code>\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30b3\u30de\u30f3\u30c9\u3082\u66f8\u304b\u308c\u3066\u3044\u307e\u3057\u305f\uff09\u304c\u3001\u73fe\u5728<code>laravel-precognition<\/code>\u3068\u3044\u3046\u30d1\u30c3\u30b1\u30fc\u30b8\u306f<code>npm<\/code>\u306b\u306f\u5b58\u5728\u3057\u3066\u3044\u306a\u3044\u3088\u3046\u3067\u3057\u305f\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u4eca\u56de\u306f<code>axios<\/code>\u3067\u76f4\u63a5<code>Ajax<\/code>\u9001\u4fe1\u3059\u308b\u3053\u3068\u3067\u5b9f\u88c5\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3069\u3046\u3084\u3089 2022.10.05 \u73fe\u5728\u3001\u958b\u767a\u8005 Tim MacDonald \u3055\u3093\u306e <a href=\"https:\/\/twitter.com\/timacdonald87\/status\/1577477786729517056\" target=\"_blank\" rel=\"noopener\">\u30c4\u30a4\u30fc\u30c8<\/a>\u00a0\u3092\u898b\u308b\u9650\u308a\u92ed\u6c17\u4f5c\u6210\u4e2d\u306e\u3088\u3046\u3067\u3059\u306d\ud83d\udc4d<\/p>\n<h2>\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\uff08\u90e8\u5206\uff09\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/h2>\n<p>\u300c<strong>\u30d5\u30a9\u30fc\u30e0\u5024<\/strong>\u300d\u30d6\u30ed\u30c3\u30af\u3067\u306f\u3001\u5165\u529b\u30dc\u30c3\u30af\u30b9\u306b\u5909\u66f4\u304c\u3042\u3063\u305f\u3089\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\uff08\u90e8\u5206\u7684\u306a\uff09\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u304c<code>Precognition<\/code>\u3092\u4f7f\u3063\u3066\u3044\u308b\u90e8\u5206\u306a\u306e\u3067\u3059\u304c\u3001\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u6d41\u308c\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<ol>\n<li>\u540d\u524d\u3092\u300c\u3042\u300d\u3068\u5165\u529b\u3057\u305f<\/li>\n<li>\u5165\u529b\u3057\u305f\u77ac\u9593\u306b\u300cPrecognition\u300d\u30e2\u30fc\u30c9\u3067\u300cname=\u3042\u300d\u3092<code>store()<\/code>\u3078\u30c7\u30fc\u30bf\u9001\u4fe1<\/li>\n<li>Precognition \u304c\u5b9f\u884c\u3055\u308c\u3001name \u3060\u3051\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3059\u308b<\/li>\n<li>\u6210\u529f or \u5931\u6557\u3092\u8fd4\u3059<\/li>\n<\/ol>\n<p>\u305d\u3057\u3066\u3001\u4eca\u56de\u306e\u30b1\u30fc\u30b9\u3067\u306f\u540d\u524d\u306e\u4ed6\u306b\u3082\u300c\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u300d\u3084\u300c\u30d1\u30b9\u30ef\u30fc\u30c9\u300d\u3082\u3042\u308b\u306e\u3067\u3001\u30a4\u30e1\u30fc\u30b8\u3067\u8a00\u3046\u3068\u300c<strong>\u98f2\u307f\u4f1a\u3067\u96c6\u307e\u308b\u30e1\u30f3\u30d0\u30fc\u306b\uff11\u4eba\u305a\u3064\u4e88\u5b9a\u3092\u78ba\u8a8d\u3057\u3066\u3044\u304f<\/strong>\u300d\u3088\u3046\u306a\u30ab\u30f3\u30b8\u3067\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066<code>Precognition\u306f<\/code>\u3053\u306e\u3088\u3046\u306b\u300c<strong>\u672c\u9001\u4fe1\u3059\u308b\u524d\u306b\u3001\u5148\u306b\u304a\u4f3a\u3044\u3092\u7acb\u3066\u308b<\/strong>\u300d\u3088\u3046\u306a\u6a5f\u80fd\u3067\u3059\u306e\u3067\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3060\u3051\u3067\u306a\u304f\u3044\u308d\u3044\u308d\u306a\u4f7f\u3044\u65b9\u304c\u3067\u304d\u308b\u3068\u671f\u5f85\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u9001\u4fe1\u90e8\u5206<\/h2>\n<p>\u30b3\u30fc\u30c9\u3092\u77ed\u304f\u3059\u308b\u305f\u3081\u306b\u4ee5\u4e0b\uff12\u3064\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u5171\u901a\u5316\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u672c\u9001\u4fe1<\/li>\n<li>Precognition\u3067\u306e\uff08\u90e8\u5206\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\uff09\u9001\u4fe1<\/li>\n<\/ul>\n<p>\u305d\u306e\u305f\u3081\u3001<code>hundleSubmit<\/code>\u306b\u306f<code>isPrecognition<\/code>\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u3064\u3044\u3066\u3044\u3066\u5206\u5c90\u3092\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001<code>isPrecognition<\/code>\u304c<code>true<\/code>\uff08\u3064\u307e\u308a\u3001\u90e8\u5206\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u3059\u308b\uff09\u306e\u5834\u5408\u306f\u3001\u9001\u4fe1\u306b\u5c02\u7528\u30d8\u30c3\u30c0\u30fc\u3092\u3064\u3051\u308b\u5fc5\u8981\u304c\u3042\u308a\u3001\u305d\u308c\u304c<code>getSubmitConfig()<\/code>\u3067\u66f8\u304b\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u3053\u308c\u3082<code>Precognition<\/code>\u3068\u306f\u95a2\u4fc2\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5408\u4f53\u90e8\u5206\u304c\u5c11\u3057\u308f\u304b\u308a\u306b\u304f\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u306e\u3067\u3001\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u90e8\u5206\u3067\u3059\u3002<\/p>\n<pre><strong>setParams({<\/strong>\r\n<strong>    ...params,<\/strong>\r\n<strong>    ...{[key]: value}<\/strong>\r\n<strong>});<\/strong><\/pre>\n<p>\u5206\u304b\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>const originalData = {<\/strong>\r\n<strong>    name: '\u5c71\u7530\u592a\u90ce',<\/strong>\r\n<strong>    email: 'taro@example.com',<\/strong>\r\n<strong>    password: 'password',<\/strong>\r\n<strong>};<\/strong>\r\n\r\n<strong>const dataKey = 'name';<\/strong>\r\n<strong>const dataValue = '\u4f50\u85e4\u6b21\u90ce';\r\n<\/strong>\r\n<strong>const newData = {<\/strong>\r\n<strong>    ...originalData,<\/strong>\r\n<strong>    ...{[dataKey]: dataValue},<\/strong>\r\n<strong>};<\/strong>\r\n\r\n<strong>console.log(newData);<\/strong><\/pre>\n<p>\u7d50\u8ad6\u304b\u3089\u8a00\u3046\u3068\u3001\u3053\u308c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre>{\r\n    <strong>\"name\": \"\u4f50\u85e4\u6b21\u90ce\", \/\/ \ud83d\udc48 key \u304c name \u306a\u306e\u3067\u3053\u3053\u304c\u4e0a\u66f8\u304d\u3055\u308c\u308b<\/strong>\r\n    \"email\": \"taro@example.com\",\r\n    \"password\": \"password\"\r\n}<\/pre>\n<p>\u3057\u304b\u3057\u3001<strong>\u30ad\u30fc\u304c\u914d\u5217\u3067\u306f\u306a\u3044\u5834\u5408\u306f\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/strong><\/p>\n<pre>const newData = {\r\n    ...originalData,\r\n    ...{<strong>dataKey<\/strong>: dataValue}, \/\/ <strong>\ud83d\udc48 \u30ad\u30fc\u304c\u914d\u5217\u3067\u306f\u306a\u3044<\/strong>\r\n};<\/pre>\n<p>\u3053\u308c\u306f<code>JavaScript<\/code>\u306e\u6027\u8cea\u4e0a\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>{\r\n    \"name\": \"\u5c71\u7530\u592a\u90ce\",\r\n    \"email\": \"taro@example.com\",\r\n    \"password\": \"password\",\r\n    <strong>\"dataKey\": \"\u4f50\u85e4\u6b21\u90ce\" \/\/ \ud83d\udc48 \u30ad\u30fc\u304c\u6587\u5b57\u5217\u3068\u3057\u3066\u5224\u65ad\u3055\u308c\u3001\u3053\u3053\u304c\u8ffd\u52a0\u306b\u306a\u308b<\/strong>\r\n}<\/pre>\n<p>\u3064\u307e\u308a\u3001\u4eca\u56de\u306e\u30b3\u30fc\u30c9\u3067\u4f7f\u3063\u3066\u3044\u308b\u306e\u306f\u300c<strong>\u30ad\u30fc\u3092\u53ef\u5909\u306b\u3059\u308b\u305f\u3081<\/strong>\u300d\u306b\u914d\u5217\u3067\u6307\u5b9a\u3057\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b<code>...<\/code>\u306e\u90e8\u5206\u306f\u300c<strong>\u30b9\u30d7\u30ec\u30c3\u30c9\u69cb\u6587<\/strong>\u300d\u3068\u8a00\u3063\u3066\u30b3\u30fc\u30c9\u3092\u77ed\u304f\u304b\u3051\u308b\u65b9\u6cd5\u3067\u3059\u3002\u3082\u3057\u8208\u5473\u304c\u3042\u308a\u307e\u3057\u305f\u3089\u3001\u305c\u3072\u4ee5\u4e0b\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\ud83d\udcdd\u00a0<a href=\"https:\/\/blog.capilano-fw.com\/?p=10057#i-5\" target=\"_blank\" rel=\"noopener\">\u30b9\u30d7\u30ec\u30c3\u30c9\u69cb\u6587\u3092\u4f7f\u3046\u3068\u7701\u30b3\u30fc\u30c9\u306b\u306a\u308a\u307e\u3059<\/a><\/p>\n<h2>\u30a8\u30e9\u30fc\u90e8\u5206<\/h2>\n<p><code>useEffect<\/code>\u3092\u4f7f\u3063\u3066\u30da\u30fc\u30b8\u8aad\u307f\u8fbc\u307f\u6642\u306b\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u4e2d\u8eab\u3092\u7528\u610f\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u306f<code>params<\/code>\u306e\u30ad\u30fc\u5168\u3066\u306b\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u7528\u610f\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u306a\u305c\u3053\u3046\u3057\u3066\u3044\u308b\u304b\u3068\u8a00\u3046\u3068\u300c<strong>\u3082\u3057\u304b\u3059\u308b\u3068\u4eca\u5f8c params \u306e\u4e2d\u8eab\u304c\u5909\u66f4\u306b\u306a\u308b\u304b\u3082\u3057\u308c\u306a\u3044\u304b\u3089<\/strong>\u300d\u3067\u3059\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u3044\u3066\u3082\u30b3\u30fc\u30c9\u306f\u52d5\u304d\u307e\u3059\u3002<\/p>\n<pre><strong>const [params, setParams] = useState({<\/strong>\r\n<strong>    name: '',<\/strong>\r\n<strong>    email: '',<\/strong>\r\n<strong>    password: '',<\/strong>\r\n<strong>});<\/strong>\r\n<strong>const [errors, setErrors] = useState({<\/strong>\r\n<strong>    name: '',<\/strong>\r\n<strong>    email: '',<\/strong>\r\n<strong>    password: '',<\/strong>\r\n<strong>});<\/strong><\/pre>\n<p>\u3057\u304b\u3057\u3001\u4f8b\u3048\u3070\u3001<code>params<\/code>\u306b\u300c\u4f4f\u6240\u300d\u3084\u300c\u5e74\u9f62\u300d\u304c\u8ffd\u52a0\u306b\u306a\u3063\u305f\u3089\u3069\u3046\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u3044\u3061\u3044\u3061\u30a8\u30e9\u30fc\u306e\u65b9\u306b\u3082\u30ad\u30fc\u3092\u8ffd\u52a0\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u4e0a\u306e\u30b3\u30fc\u30c9\u306f\u5834\u6240\u304c\u8fd1\u3044\u304b\u3089\u554f\u984c\u306f\u5c11\u306a\u3044\u3067\u3059\u304c\u3001\u4eca\u56de\u306e\u3088\u3046\u306b\u6a5f\u80fd\u3054\u3068\u306b\u30b3\u30fc\u30c9\u3092\u5206\u3051\u3066\u3044\u308b\u5834\u5408\u3001\u9ad8\u3044\u78ba\u7387\u3067\u300c<strong>\u30a8\u30e9\u30fc\u306e\u30ad\u30fc\u3092\u8ffd\u52a0\u3059\u308b\u306e\u3092\u5fd8\u308c\u308b<\/strong>\u300d\u3068\u3044\u3046\u30df\u30b9\u304c\u767a\u751f\u3057\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f<code>params<\/code>\u3092\u30eb\u30fc\u30d7\u3057\u3066\u5404\u30c7\u30fc\u30bf\u306b\u5bfe\u3059\u308b\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u81ea\u52d5\u3067\u7528\u610f\u3057\u3066\u3044\u307e\u3059\u3002\uff08\u3053\u308c\u3001\u30a2\u30f3\u30c1\u30d1\u30bf\u30fc\u30f3\u3058\u3083\u306a\u3044\u3067\u3059\u3088\u306d\u2757\u2753\uff09<\/p>\n<p>\u4ee5\u4e0a\u3067\u4f5c\u696d\u306f\u7d42\u4e86\u3067\u3059\u2757<br \/>\n\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\ud83d\ude04\u2728<\/p>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b<code>Precognition<\/code>\u3092\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u2757<\/p>\n<p><code>Vite<\/code>\u3092\u8d77\u52d5\u3057\u3066\u300c<strong>http:\/\/******\/precognition_form<\/strong>\u300d\u3078\u30d6\u30e9\u30a6\u30b6\u3067\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u3002<\/p>\n<p>\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d5\u30a9\u30fc\u30e0\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11086\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_1.png\" alt=\"\" width=\"640\" height=\"393\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_1.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_1-300x184.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u3067\u306f\u3001\u540d\u524d\u306e\u90e8\u5206\u306b\u300c<strong>abc<\/strong>\u300d\u3068\u5165\u529b\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u2757<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11087\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_2.png\" alt=\"\" width=\"364\" height=\"305\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_2.png 364w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_2-300x251.png 300w\" sizes=\"auto, (max-width: 364px) 100vw, 364px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u4eca\u56de\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\uff08\u3042\u307e\u308a\u9069\u5207\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u304c\uff09\u300c<strong>\u540d\u524d\u306f\uff15\u6587\u5b57\u4ee5\u4e0a<\/strong>\u300d\u3068\u3044\u3046\u30eb\u30fc\u30eb\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u30a8\u30e9\u30fc\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u3067\u306f\u3001\u7d9a\u3051\u3066\u300c<strong>de<\/strong>\u300d\u3092\u8ffd\u52a0\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u3059\u308b\u3068\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11088\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_3.png\" alt=\"\" width=\"360\" height=\"279\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_3.png 360w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_3-300x233.png 300w\" sizes=\"auto, (max-width: 360px) 100vw, 360px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u6587\u5b57\u304c\uff15\u6587\u5b57\u4ee5\u4e0a\u306b\u306a\u3063\u305f\u306e\u3067\u30a8\u30e9\u30fc\u304c\u6d88\u3048\u307e\u3057\u305f\u3002<\/p>\n<p><code>Precognition<\/code>\u3001\u6210\u529f\u3067\u3059\ud83d\ude04\u2728<\/p>\n<p>\u3067\u306f\u3001\u3053\u306e\u72b6\u614b\u3067\u9001\u4fe1\u3092\u3057\u3066\u3082\u30a8\u30e9\u30fc\u304c\u3061\u3083\u3093\u3068\u8868\u793a\u3055\u308c\u308b\u304b\u30c1\u30a7\u30c3\u30af\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u3069\u3046\u306a\u3063\u305f\u3067\u3057\u3087\u3046\u304b\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11089\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_4.png\" alt=\"\" width=\"640\" height=\"416\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_4.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_4-300x195.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u300c<strong>\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9<\/strong>\u300d\u3068\u300c<strong>\u30d1\u30b9\u30ef\u30fc\u30c9<\/strong>\u300d\u306b\u30a8\u30e9\u30fc\u304c\u51fa\u307e\u3057\u305f\u3002<\/p>\n<p>\u3067\u306f\u3001\u6700\u5f8c\u306b\u3059\u3079\u3066\u6709\u52b9\u306a\u5165\u529b\u306b\u3057\u3066\u9001\u4fe1\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11091\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_6.png\" alt=\"\" width=\"640\" height=\"328\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_6.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_6-300x154.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u3046\u307e\u304f\u3044\u304f\u3067\u3057\u3087\u3046\u304b\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11090\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_5.png\" alt=\"\" width=\"489\" height=\"182\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_5.png 489w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/10\/laravel_precognition_5-300x112.png 300w\" sizes=\"auto, (max-width: 489px) 100vw, 489px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u30a2\u30e9\u30fc\u30c8\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u3059\u3079\u3066\u6210\u529f\u3067\u3059\u2728\ud83d\ude04\ud83d\udc4d<\/p>\n<h1>\u30c7\u30e2\u30da\u30fc\u30b8\u3092\u3064\u304f\u308a\u307e\u3057\u305f<\/h1>\n<p>\u4eca\u56de\u3082\u305b\u3063\u304b\u304f\u306a\u306e\u3067\u30c7\u30e2\u30da\u30fc\u30b8\u3092\u3064\u304f\u3063\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u305c\u3072\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u304b\u3089\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\ud83d\udcdd <a href=\"https:\/\/demo-laravel9x-vite.capilano-fw.com\/precognition_form\/create\" target=\"_blank\" rel=\"noopener\">\u30c7\u30e2\u30da\u30fc\u30b8<\/a><\/p>\n<h1>\u4f01\u696d\u69d8\u3078\u306e\u3054\u63d0\u6848<\/h1>\n<p>\u4eca\u56de\u306e\u3088\u3046\u306b<code>Precognition<\/code>\u3092\u4f7f\u3063\u3066\u5b9f\u88c5\u3059\u308b\u3068\u30e6\u30fc\u30b6\u30d3\u30ea\u30c6\u30a3\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3082\u3057\u305d\u3046\u3044\u3063\u305f\u3054\u5e0c\u671b\u304c\u3054\u3056\u3044\u307e\u3057\u305f\u3089\u3001\u3044\u3064\u3067\u3082\u300c<strong>\u304a\u554f\u3044\u5408\u308f\u305b<\/strong>\u300d\u304b\u3089\u304a\u6c17\u8efd\u306b\u3054\u9023\u7d61\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u304a\u5f85\u3061\u3057\u3066\u304a\u308a\u307e\u3059\u3002m(_ _)m<\/p>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u300c<strong>Laravel + React<\/strong>\u300d\u3067\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\uff08\u90e8\u5206\uff09\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><code>Precognition<\/code>\u3068\u3044\u3046\u65b0\u6a5f\u80fd\u304c\u8ffd\u52a0\u3055\u308c\u305f\u3053\u3068\u3067\u3001\u4eca\u5f8c\u3088\u308a\u9762\u5012\u3060\u3063\u305f\u3053\u3068\u304c\u30b7\u30f3\u30d7\u30eb\u306b\u5b9f\u88c5\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u53ef\u80fd\u6027\u3092\u611f\u3058\u3055\u305b\u3089\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u3082\u958b\u767a\u306e\u52b9\u7387\u5316\u3092\u76ee\u6307\u3057\u3066\uff08\u79c1\u306e\u5834\u5408\u306f\u697d\u3059\u308b\u3053\u3068\u3092\u76ee\u6307\u3057\u3066\uff09\u8a66\u3057\u3066\u898b\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u2757<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6068 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_12.png\" alt=\"\" width=\"226\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_12.png 226w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_12-212x300.png 212w\" sizes=\"auto, (max-width: 226px) 100vw, 226px\" \/>\u300c\u5e74\u3068\u3068\u3082\u306b<br \/>\n\u30b3\u30fc\u30d2\u30fc \u2192 \u304a\u8336 \u2192 \u767d\u6e6f<br \/>\n\u3068\u5909\u5316\u3002\u9000\u5374\u6226\u307f\u305f\u3044\u3067\u3059\u306d\ud83d\ude02\u300d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u300c\u3055\u3059\u304c\u306b\u3082\u3046Laravel\u306e\u9032\u5316\u306f\u6b62\u307e\u308b\u3067\u3057\u3087\u300d\u3068\u4f55\u5ea6\u304b\u8003\u3048\u305f\u3053\u3068\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u7686\u3055\u3093\u3082\u3054\u5b58\u77e5\u306e\u901a\u308a\u307e\u3060\u307e\u3060\u9032\u5316\u306f\u6b62\u307e\u308b\u3053\u3068\u306f\u306a\u3055\u305d\u3046\u3067\u3059\u3002 \u3068\u3044 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=11085\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel Precognition \u3067\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u30fb\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u3064\u304f\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":11095,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[247,3,118,249,248],"tags":[],"class_list":["post-11085","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-inertia-js","category-laravel","category-react-js","category-tailwind-css","category-vite"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/11085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11085"}],"version-history":[{"count":6,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/11085\/revisions"}],"predecessor-version":[{"id":11098,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/11085\/revisions\/11098"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/11095"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}