Meraj
RReactiflux
•Created by Meraj on 4/6/2023 in #react-forum
Component not showing data after useRef
Hello,
A little explanation before the code:
I am fetching data from a database asynchronously. Fetches just fine using the function
fetchData
. Then to stop continuous re-rendering I use useRef instead of useState to set two arrays cdata
and pdata
. Their console.log
shows it worked.
However, when I call my component after onclick
neither cdata
nor pdata
are available.
I cant use useEffect
as I need my data to be available after onclick
and fetchData
within useEffect
means it is only available after the page re-renders. Not at onclick
.5 replies
RReactiflux
•Created by Meraj on 3/23/2023 in #react-forum
Cannot fetch data for a component from an API
Hello,
I want to fetch data that I successfully collect from a mongodb database and then display it in a dropdown component. But I am unable to receive it and receive
undefined
instead.
This is my API, a [...param].js
in folder api/calcCart
:
This is the function where I fetch this usersArray
. It is in index.js
:
This is the component where this function is called, also defined in index.js
:
I keep seeing this:
If it is being resolved successfully, why is there undefined?
If someone could kindly guide me. I have been on this for almost two weeks. Thank you.5 replies
RReactiflux
•Created by Meraj on 12/28/2022 in #react-forum
Cannot display table using React
Hi,
I am trying to display a simple table but it is showing me error. Been stuck on this for two weeks.
Here is my code on codesandbox: https://codesandbox.io/s/angry-gauss-lvsrn3?file=/src/App.js
Embedding it here too:
The error:
userArranged[0].map is not a function
Can someone help me out please?8 replies