I want to render the star1.png located in src/images/ directory without using import at the top and without using the public directory. My code: Answer I found the answer to my question which is using require:
Tag: reactjs
start and end date should be different for one year
Hi there I’m using Yup as a validator for one of my schemas This is my code here for validating schema This works but I can add the same date for the start date and end date. I want that end date to be different and higher than start date Thanks a lot Answer You can try Yup.when to handle
Re-render Header on Firebase Login
I’m having a problem getting my header to update after I log in with Firebase… When I refresh my browser it goes back to as if I am not logged in until I am redirected. I want to re-render my header when the user is detected as logged in after refresh. This is my current method of changing the hea…
how to give string value on y axis in rechart
I am working on Recat.js and using rechart library for chart implementation. I want to give string value on the y axis as label and workout on some numbers included in the json data in x axis. here Iam giving my code I don’t why its not working properly. the value key pair has to gone through x axis and
Any method to use single useState()
What I wanted to know ,that is there any method / technique to replace many useState() hook in one hook. Like, Instead of writing the whole thing again and again , we define it any one of them. Answer You can create a state object and use it. Note: When you set state, make sure you merge with the previous
React.js, Each child in a list should have a unique “key” prop. how to fix if key is already given
Im getting the warning Warning: Each child in a list should have a unique “key” prop.. My understanding of react was that when you pass to a new component you give it the Id of a prop, which i am doing, yet im still getting this warning. In my code i have some dummy data that is used to set
Can I get a JSON object with name value?
I’m trying to make a Covid-19 tracker App by ReactJS. I want to get data that only an object (a specific province value) from JSON API with ProvinceChange event. Problem : I can’t get data that is only an object (a specific province value). what I tried : I tried a method filter using province.nam…
Prevent Event Listener firing event multiple times
I am using this event listener to fire an event which basically updates my state of Interval in a useEffect and enabling me to go up and down in my table. The up and down approach working fine for me but its firing the event multiple times. This multiple times firing of event causing the top and down events w…
Axios: How to render API item base on spesific child element?
Hi Everyone I am new in ReactJS and also in Axios. I try to get data from Instagram Api and i want to render a Image if image has spesific letter in caption for example if caption has ‘Y’ letter should render on page otherwise not. With my code i render all post from profile but i cant sort the
how to store value of 2 inputs dynamically generated in state at once
i am using react.i have 2 inputs that by clicking a button dynamically ganerats. this the code: i need to save value of 2 inputs together in an opjects like this : and the new 2 input’s value are going to update the above array like this: i can save each input’s value separately like this : but i …