質問編集履歴
1
書式の改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
### React&laravelでユーザー認証をしたい
|
2
2
|
|
3
3
|
laravel&Reactでユーザー管理機能の実装をしたいとおもっております。
|
4
|
-
Reactのコンポーネントなどは作成したのですが、うまく表示がされません。
|
4
|
+
Reactのコンポーネントなどは作成したのですが、React-Routeの導入をするとうまく表示がされません。
|
5
5
|
解決策が見つからず、停滞してしまったので、知見を貸していただきたいです。
|
6
6
|
|
7
|
+
React-Routeの機能を実装中下記のようなエラーに遭遇しました。
|
8
|
+
|
7
9
|
### 発生している問題・エラーメッセージ
|
8
10
|
|
9
11
|
```
|
@@ -20,91 +22,8 @@
|
|
20
22
|
at workLoopSync (app.js:128543)
|
21
23
|
```
|
22
24
|
|
23
|
-
### Controllers/Auth/ReactController
|
24
25
|
|
25
|
-
```
|
26
|
-
<?php
|
27
26
|
|
28
|
-
namespace App\Http\Controllers\Auth;
|
29
|
-
|
30
|
-
use App\Http\Controllers\Controller;
|
31
|
-
use Illuminate\Http\Request;
|
32
|
-
|
33
|
-
class ReactController extends Controller
|
34
|
-
{
|
35
|
-
public function index(Request $request)
|
36
|
-
{
|
37
|
-
return view('react');
|
38
|
-
}
|
39
|
-
|
40
|
-
public function session(Request $request)
|
41
|
-
{
|
42
|
-
return $request-> user();
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
```
|
47
|
-
|
48
|
-
###route
|
49
|
-
```
|
50
|
-
<?php
|
51
|
-
|
52
|
-
use Illuminate\Support\Facades\Route;
|
53
|
-
|
54
|
-
Route::get('/', function () {
|
55
|
-
return view('welcome');
|
56
|
-
});
|
57
|
-
|
58
|
-
Auth::routes(['verify' => true]);
|
59
|
-
|
60
|
-
Route::get('/login', 'App\Http\Controllers\Auth\ReactController@index')->name('login');
|
61
|
-
Route::get('/register', 'App\Http\Controllers\Auth\ReactController@index')->name('register');
|
62
|
-
Route::get('password/reset', 'App\Http\Controllers\Auth\ReactController@index')->name('password.request');
|
63
|
-
Route::get('password/reset/{token}', 'App\Http\Controllers\Auth\ReactController@index')->name('password.reset');
|
64
|
-
Route::get('email/verify', 'App\Http\Controllers\Auth\ReactController@index')->name('verification.notice');
|
65
|
-
|
66
|
-
Route::post('/session', 'App\Http\Controllers\Auth\ReactController@session')->name('session');
|
67
|
-
Route::get('/{router}', 'App\Http\Controllers\Auth\ReactController@index')->name('home');
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
|
72
|
-
```
|
73
|
-
|
74
|
-
###Veiw
|
75
|
-
```
|
76
|
-
<!DOCTYPE html>
|
77
|
-
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
78
|
-
<head>
|
79
|
-
<meta charset="utf-8">
|
80
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
81
|
-
|
82
|
-
<!-- CSRF Token -->
|
83
|
-
<meta name="csrf-token" content="{{ csrf_token() }}">
|
84
|
-
|
85
|
-
<title>{{ config('app.name', 'Laravel') }}</title>
|
86
|
-
|
87
|
-
<!-- Fonts -->
|
88
|
-
<link rel="dns-prefetch" href="//fonts.gstatic.com">
|
89
|
-
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet" type="text/css">
|
90
|
-
|
91
|
-
<!-- Styles -->
|
92
|
-
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
|
93
|
-
</head>
|
94
|
-
<body>
|
95
|
-
<div id="react-root"></div>
|
96
|
-
<script>
|
97
|
-
var laravelSession = {};
|
98
|
-
laravelSession['status']=@if(session('status'))'{{session('status')}}'@else''@endif;
|
99
|
-
laravelSession['resent']=@if(session('resent'))'{{session('resent')}}'@else''@endif;
|
100
|
-
var laravelErrors=@php print(htmlspecialchars_decode($errors))@endphp;
|
101
|
-
</script>
|
102
|
-
<!-- Scripts -->
|
103
|
-
<script src="{{ asset('js/app.js') }}" defer></script>
|
104
|
-
</body>
|
105
|
-
</html>
|
106
|
-
```
|
107
|
-
|
108
27
|
###route/index.js
|
109
28
|
```
|
110
29
|
import React from 'react'
|
@@ -267,12 +186,12 @@
|
|
267
186
|
```
|
268
187
|
|
269
188
|
###試したこと
|
270
|
-
Routeなどのバージョンを再度見直し、React-router-domでV6を使用していたが、他のエラーが発生したので、バージョンを変更した。
|
189
|
+
Routeなどのバージョンを再度見直し、React-router-domでV6を使用していたが、他のエラーが発生したので、バージョンを変更しました。
|
271
190
|
|
272
191
|
|
273
192
|
###聞きたいこと
|
274
|
-
・バージョン
|
193
|
+
・バージョンの依存関係があるのでしょうか。
|
275
|
-
・エラー
|
194
|
+
・コンポーネントの作成時には問題なく表示されていたのですが、React-Routeの機能を使うとどうしてもエラーがでてきてしまいます。
|
276
|
-
・ユーザー管理機能で参考のものがありましたら、教えていただきたいです。
|
195
|
+
・もしユーザー管理機能で参考のものがありましたら、教えていただきたいです。
|
277
196
|
|
278
197
|
よろしくお願いいたいします。
|