Category "reactjs"

React useState - using one State per component vs multiples states? [closed]

What is a better way to optimize and do the code more readable in React using Hooks / Functional components; Having a single setState hook or

Is it possible to have README docs appear first in Storybook navigation, then all stories after?

I have all Storybook stories nested under a “Docs” header. Every component gets a README mdx file, then as many stories as necessary. I would like f

Github - unexpected disconnect while reading sideband packet

I've got quite interesting problem. I tried to send some projects via bash to repo and recently there was a problem with sending it. Enumerating objects: 27, do

react-router-dom useParams() inside class component

I'm trying to load a details view based on a react-router-dom route that should grab the URL parameter (id) and use that to further populate the component. My r

Reading Cookie from React (backend with FastAPI + fastapi-jwt-auth)

I am having some problems with understanding JWT in Cookie using Axios and FastAPI. I am trying to make a simple application with React for the frontend and Fas

'Routes' is not defined react/jsx-no-undef

So I was following the React Crash Course on YouTube for Beginners from Academind. I was following everything along and everything was good until I came to the

How do I host Laravel and Inertiajs (React) app in cPanel?

I built a laravel with inertiajs App, Now I'm going to deploy my app to some host. I tried Siteground to deploy it but it doesn't support NPM! Now I'm trying to

Electron with React- trying to import ipcRenderer - preload.js is not being called

I'm trying to send data fron the page to electron using ipc When I run the elctron app, the window.ipcRenderer is just undifined(inside the electron app) this i

React-Hook-Form - defaultValues not updated are not registered

I have a form who get updated directly when an user change an input. For that, I use the onBlur method. When I change an input from the defaultValue, it save it

IntersectionObserver with React & Hooks

I'm trying to track element visibility with React/Hooks and the Intersection Observer API. However, I can't figure out how to set up observation with "useEffect

Is there a more functional way to merge and foreach/sort two arrays in TypeScript, React?

I'm learning React and TypeScript. For sake of practise, I've tried to create a calculator design by merging two arrays to map a single array onto the grid (dis

How can I test google.maps.Geocoder?

Hi! I'm attempting to write a "simple" test to check for a react class component state change. Specifically, I'm testing if the lat(latitude) and lng(longitu

how to solve Matched leaf route at location "/project" does not have an element error?

I'm learning react routing but when I try to use BrowserRouter I'm getting the following error: Matched leaf route at location "/project" does not have an elem

Argument of type 'AsyncThunkAction<any, void, {}>' is not assignable to parameter of type 'AnyAction'

store.ts export const store = configureStore({ reducer: { auth: authReducer }, middleware: [], }); export type AppDispatch = typeof store.d

How can I stop a react-query useQuery running on a refetchInterval when a condition is met?

I have a requirement to keep fetching data until a condition is met I can set up the fetch on an interval with the snippet below but I can't figure out how to s

How to properly use ref with indiana drag scroll to set initial scroll position

I've been trying to implement the initial scroll from https://codesandbox.io/s/react-indiana-drag-scroll-initial-scroll-getelement-99o6q?file=/index.js:317-382

Backend Api error (502 bad gateway) from React Cilent to Express Server during deployment

I am trying to deploy my app on digital ocean (react-express app). During deployment, I used to make my requests to the following endpoint "http://localhost:800

How would I add a auto scroll feature to this code?

https://codepen.io/hexagoncircle/pen/jgGxKR?editors=0110 I was looking around for cool code to play around with and found this. I tried the classic google the

How to add custom font in react-pdf/pdf

Can anyone say how to add custom font with @react-pdf/pdfkit in react.js? I tried to use doc.registerFont(path, font_family) But its showing an error like Unhan

React - get data with axios

In my react app that is based on class components, My response API got from open weather fixes after several lags. this is my state class Weather extends Compon