In ProtectedRoute.js I have coded: and in App.js I have written as: Error says: [ProtectedRoute] is not a Route component. All component children of Routes must be a Route or <React.Fragment>. Is there something missing! Thank you Answer In react-router-dom custom route components are no longer used. Routes components can have only Route and React.Fragment components as children, and Route
Tag: reactjs
How to post a form with fetching?
I am trying to send a post with fetch an API. My fetch is working because it returns 200 and sends the request but it sends an empty form. It cannot take the values in the form input. Where is my mistake and how can I fix it? Answer [Update]: You can either remove the application/json header and let browser
How user string input will show as background color in a div in react JS functional component
I am trying to make a color box where users can input color as a string but will display output as a background color in react I tried this way but it did not work as expected I am just learning to react. thanks in advance Here is my code. ); } Answer I’m not sure this is what you
Custom Audio Player in react JS – Volume Control
I am building an custom audio player in React JS, I am current stuck with the volume controls in the audio player Here is my code Progress bar works fine, What should be logic behind the volume control AduioPlayer.js changeRange function : changePlayerCurrentTime function : Answer Audio HTML Elements have a volume property you can access. You will need to
How to navigate from one screen to another in React native?
When I click on Sign Up button I want to navigate to Sign up page but it did not work. I have imported the screens and navigated screen also to app.js file. I am getting an ReferenceError : Can’t find variable: navigation. Also I am unable to insert background image? Below is the Sign Up page. Answer onPress handler does
How to use a custom React hook to make a POST or DELETE request with Axios
I am trying to make a generic useAxios hook in React. I would like to be able to import this hook into other components to make Get, Post, and Delete requests. I have created the hook and it works fine for making Get requests, but I am stuck on how to make it work for Post/Delete requests. The issue is
how can i use Route without getting any errors like this
Guys i’m trying to work on my navigation bar and use route but it always shows errors I don’t know the reason but it isn’t convinced with the routes at all and the error is below is my app.jsx code and my navigation is this code as well though i was working navlink and yet it didn’t work and showed
Server Error ReferenceError: window is not defined in Next.js
I’m trying to integrate CleverTap into my Next.js app. Followed the documentation Web SDK Quick Start Guide but facing issue: Server Error ReferenceError: window is not defined in Next.js _app.tsx cleverTapHelper.ts cleverTap.d.ts Window object should not be undefined but getting undefined! What’s going on? Answer This is because NextJS is trying to execute that function on the server because it
Rewriting React router v4 class based code to v6 functional based
I’m trying to implement oauh login with react and spring boot and I’ve found a tutorial I can follow. The issue I have is that it is using React Router v4, I would like to update it to use React Router v6 and using Functional components instead. Login.js App.js This is the App.js with the routes, I have updated it
How to pass props from one Component to another component with onClick() event in React.js
Quick Help Needed! I have Two React components Vendors and VendorsList. In Vendors.js Component i have asset.asset_name text rendered in table format. What I want is, When I click on I asset.asset_name, I wanted to pass it’s value from Vendors component to VendorsList component. How could I do this? Here is code for Two Components Vendors.js Here is VendorsList.js I