All Questions
Tagged with javascript react.js
291 questions
1
vote
1
answer
89
views
React component
The code makes unnecessary API calls because there are two useEffect hooks that both fetch data. The first useEffect runs on mount and fetches data for page 1, while the second useEffect runs whenever ...
1
vote
1
answer
79
views
Extract each occurrence from an array of objects
I have a huge list of 4k+ software products.
My goal is simple. I have a list of products. Each of those products has a software value. I would like to extract each software occurrence and covert it ...
3
votes
0
answers
78
views
React draggable sliding panel
I'm building a sliding bottom panel as a React component, adapting Phuoc Nguyen's excellent draggable element tutorial.
It currently looks like this:
The expected behavior is:
User taps on button to ...
1
vote
1
answer
69
views
How to encapsulated javascript code using imutable method?
I have this code, but I need to return pure functions instead the mutating functions.
Is it possible? Perhaps using OOP? I don't know how to improve it.
I tried to return the values in each function, ...
4
votes
1
answer
102
views
access arrow data
I am fetching arrow tabular data from an API. The content-type of the response is application/vnd.apache.arrow.stream. In my react code, I am trying to read the ...
1
vote
0
answers
85
views
Variable button increment picked from an input:range in React 18
I'm a newbye in React. I created some simple Components to practice. For now, I'm using class Component (I want learn either class COmponent or function COmponent).
I would know if I projected ...
1
vote
1
answer
82
views
Tracking people's check-in and check-out at an event
I have some logic that helps me calculate the data for a summary of an event, which should be rendered as something like this:
...
0
votes
1
answer
39
views
Choose a marker for the map based on the alerts it has
I need help to refactor this code, I think I can avoid the first two functions that filter the array. Also in the third part where I use the result of these two filters:
...
1
vote
1
answer
77
views
PaginationBar component that renders links or buttons depending on optional callback prop
I have several components/pages in my personal project that contain complex logic and even nested ternary operators. Since I'm the only person working on this project, I don't have a hard time ...
0
votes
2
answers
121
views
How to write repetitive styled components in a cleaner way
I'm using Styled Components for styling and there are many icons defined in the project so in the style file we have this code:
my-component.styles.ts
...
2
votes
2
answers
273
views
React component which uses another component for rendering
Having this React component:
...
1
vote
1
answer
310
views
React Custom hooks - useFetch
I created custom hooks, which allows to fetch the API using two request methods 'GET' and 'POST'.
Use cases:
...
1
vote
1
answer
489
views
Constructing routes from imported URL constants
There is a file created with the project paths in a dictionary.
Example:
...
0
votes
1
answer
117
views
Doubling of state to speed up UI performance in React with Redux
I have a settings section to my UI which keeps track of a myriad of user settings. The settings are requested from an API when the app loads, and then used in the section to populate what the user's ...
0
votes
1
answer
59
views
Elegant defensive checks for nested values
I have the following function where data may not exist during the many nested steps
to obtain data. To prevent errors, doing the checks as follows.
Is there a more elegant way to do this?
Please ...