'Button onClick not working in React x Laravel
Hello everyone i am quite lost right now, in my other react projects onClick is working just fine but now with my new app laravel with react i cannot do an Onclick this is crazy i dont know where the problem is because i have no error in the console...
EDIT
I finally found the problem, i imported twice a js file in my layout
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
<!-- Fonts -->
<link rel="dns-prefetch" href="//fonts.gstatic.com">
<link rel="stylesheet" href="{{ asset('css/bootstrap.css')}}">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
</head>
<body>
@if (Auth::user())
@include('inc.navbar')
@endif
<main class="py-4">
@yield('content')
</main>
<script type="text/javascript" src="js/app.js"></script>
Solution 1:[1]
can you try please to add to the button tag ( type="button" ) , if its not working try to remove the taskform component to check if there is error in the component
Solution 2:[2]
I also just faced this problem when using laravel 8 mix react 17, the solution is to downgrade to react 16.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | mmantach |
Solution 2 | iamphonghg |