63 questions from the last 30 days
Advice
2
votes
11
replies
115
views
Need to display plaintext passwords to teacher for 2nd grader accounts
I'm working on an amplify website which has 2 cognito account types, a teacher and students created by this teacher. These are 2nd graders who often forget passwords/have to have teacher look them up ...
Best practices
1
vote
4
replies
125
views
fetching from an API in react
so to fetch from an API in react we can either use the useEffect(), or a combination of useEffect() and useCallback(), but there is a very annoying problem that I see most of the time where we get ...
-1
votes
2
answers
119
views
Why is callback reference not observed in useEffect
How do I render a div in a component conditionally based on a component property and the get a reference to that div when it's available?
In this simplified example, the message displayed in the div ...
0
votes
3
answers
159
views
Is it okay to use setState inside a setState callback?
Illustrative example:
export const App = () => {
const [things, setThings] = useStoredState(window.localStorage, 'things', [
{ id: 0, name: 'New Thing' },
]);
const [selectedThingId, ...
-4
votes
1
answer
116
views
Query a Database for a subcategory based on the URL path when subcategories at different levels might have the same name
In my shop I have multiple levels of nested categories (100s of categories with the same item available under multiple categories) for example:
.
├── clothes
│ ├── mens
│ │ ├── brand a
│ │ │ ...
1
vote
3
answers
84
views
Rerender same component with new route params
I have a category page that is supposed to display category info depending on the category route.
My route is:
<Route path="/category/*" element={<CategoryPage />} />
I can have ...
-3
votes
0
answers
128
views
Avoiding delay when using search params as state [closed]
I noticed when deriving state using Route.useSearch(), and updating state using Route.useNavigate, there is a delay when updating state. Is there guidance on how to do this optimally? So far I'm ...
2
votes
2
answers
111
views
Images not loading when hosting Next.js application on GitHub Pages
I've had a number of issues getting my Next.js to build and load using GitHub Pages. The final problem I am having now is that the images are not loading and it appears to be a problem with the image ...
-1
votes
2
answers
86
views
How can I update field state directly, quickly from AI stream?
I'm working on a text editor with my editor input being a react-hook-form field. I also have an AI writing assistant that streams text from the back-end that I need to update the input as it streams. ...
Best practices
1
vote
4
replies
98
views
How to properly manage authentication with Axios and React Context in a TypeScript app?
I’m building a React + TypeScript app and using Axios for API requests. I have an AuthProvider using React Context to manage the user and token, and I’m running into a few questions and issues:
Do I ...
Best practices
0
votes
2
replies
47
views
How can we access the img from one folder to another in React.js?
I am doing a React API project where in my assets folder I have my logo, and in another folder, a component called Navbar.js is there. I want the logo in that file. How can we do that ? Is there ...
-3
votes
0
answers
104
views
How to read in local file in react [duplicate]
This should be simpler. I am writing a demo of some proposed solution. I need to initialize a react component (a react-quill editor if it matters) with the contents of a file. In our final solution,...
-1
votes
0
answers
98
views
Trivial TypeORM on React App using Ionic/Capacitor 8/SqLite gives "emitDecoratorMetadata"/"reflect-metadata" error
I'm trying to setup a trivial example app using TypeORM. I followed several sources from the typeorm site, git projects, and even AI, but it is a mess! Some instructions are for cordova plugin and ...
-1
votes
0
answers
102
views
TypeScript error in vite.config.ts: 'test' does not exist in type UserConfigExport when configuring Vitest [closed]
I have been battling this issue for a while now, setting up Vitest in a react and typescript project, vitest does run from the cli but typescript reports an overload error in vite.config.ts
the exact ...
0
votes
1
answer
82
views
Vite + React + TypeScript failing to resolve @/components import path
I'm working on a React + TypeScript project using Vite. When I run npm run dev, I get an import resolution error:
Error: Failed to resolve import "@/components/layout/AppLayout"
Project ...