I’ve user object in local storage. I stored token and token date here User object like that; I parse JSON and get data then sending header with Axios. But i don’t want to be code repetition. How do i that? I hear react-component-lib is it right to use this? And last thing i don’t know Redux.…
Tag: reactjs
Dynamically return Values from Axios-Request within function
How do I wait and/or build a return with values that come from an API-Call via axios in react? The problem im Facing is that axios requests are asynchronous. Thats why the return from my code is hit earlier then the response from my request arrives. I’m trying to build Cards from a Weather API (openweat…
Navigate between different components React Native
So I’ve been trying to understand how to do this for like 2 hours now but I can’t seem to figure it out. I want to be able to go from one component to another when the button is clicked. First.js Second.js So I cut out some of my code with all the extra stuff but above is the two
Custom hook when taking data in next render lost data
I made a hook useSendFormData , when i use it i get Invalid hook call. Hook takes data from SubmitForm url:string, method: post or put success: success message if it was success id: not required but if item has id i is added to api call. auth default false Problem is it loses data on renders I don’t kno…
React form is sending only one property of state, rather than entire state
I am attempting to send form data from my react client to my nodejs server; however, upon submitting the form, only the last property of the state is sent to my server. I know this is a client side issue, since with Postman, my entire form data is sent to my database. It seems when I add a value to
Cannot read property ‘reduce’ of undefined data from firebase
I am trying to git the totalBalance of but i face error Cannot read property ‘reduce’ of undefined and in the same time i can iterate on the clients of the component the code is the below i thought the issue is clients is undefined but i don’t know the reson Answer This error is telling you …
Getting problem in making a timer/ count-down code in ReactJs
I am getting a problem in making a countdown timer which will start on clicking on start button and it will stop onClicking on the stop button. I have made that thing on javascript but when I came to reactJs, I am getting unable. I am providing all the codes. And please check what is the problem. Answer Issue…
FlatList scrollToIndex out of range
I have a FlatList where I’m trying to scroll through each index of my data array every X amount of seconds. There’s only two items in my array right now but there could be more. The current code works for the first two iterations but then it does not seem to reset properly and I get the scrollToIn…
React leaflet map center not changing
I’m setting up a map to find the coords of a person and then put that location on the map. But for some reason, the coords aren’t being shown on the map. I console.log to make sure the state variables(where the coords are being stored) were emitting the right coords and they are. I don’t kno…
Why can’t `useCallback` always return the same ref
I don’t understand why useCallback always returns a new ref each time one of the deps is updated. It results in many re-render that React.memo() could have avoided. What is, if any, the problem with this implementation of useCallback? Using this instead of the built-in implementation sure has a signific…