How to I get access to the history function when passing custom props to component. If I try getting the history object in Home component, I can’t get to use the history functions. I logged the history object in the console and I can see there’s not push or replace functions anymore. Where as, usi…
Tag: reactjs
React set a state to the result of an API call
I’m making a call to a getTime function which returns the datetime, but for some reason the state I specify is not being updated, am I misunderstanding how this works? Do I need to await the result? Answer Yes, exactly, it’s a fetch, so you gotta wait for the result and set the state only then, so…
Recursive function in useImperativeHandle
My code is like below but I getting checkSome is not defined error, from inside the checkSome function, how can I call checkSome(el) Answer You need to use this keyword. Try this: You can read more from here.
React: How can I show an already existing image in react update form and then show the new one once a new image is uploaded?
hey guys i am learning react js and I have an update form to update book info. I am using django rest api for endpoints. I have a working form where I can upload files and do all those stuffs but I am not able to show the image which is already there in the template, Here I have a
css modules in react
I am having some trouble with css modules in react I dont know how to use react modules in a dynamic way I want to be able to display the classes showing the value that corresponds to the element in state . is this even possible or should I approach the problem differently I want to be to do some
Reactjs: Best approach to avoid 1 API failure affects other API calls for multiple API calls inside react componentDidMount
I’m writing a react component which requires TWO or MORE API calls inside componentDidMount as below. The 2 API calls will update 2 different states and thus two different child components will be re-rendered. However, I believe what I wrote is not the best approach, since potential failure of one API w…
React Error: “SharedArrayBuffer is not defined” in Firefox
I have a React app, created with ‘create-react-app’ (I also use jsdom NPM package), and for some reason, the application throws an error on load Only in Firefox (works fine in Chrome & Edge). Here is the error: After some Googling I found: “To enable SharedArrayBuffer in Firefox, go to a…
React Router does not recognize direct address line changing in laravel
I use React Router and Laravel. When I navigate throught Link elements all OK, but when I change browser address line to manually show another component Laravel shows it defalt 404 page. This is default web.php content, in welcome.blade.php I inlcude js/app.js file: This is my App.js content: app.js: So, how …
Build a tree array (3 dimensional) from a flat array in Typescript/Javascript
I have incoming data in this format: I want the output to be something like this: Basically, it is a three dimensional array with first level being the Countrie, second States and third Cities. I have tried the following code: But the above code works upto second level and does not add cities to states. Could…
How to display data dynamically with ant design tables
first please my javascript skill level is not good, but here… I have a table i got from ant.design, im trying to build a frontend with react, so I want to display some data on the table from my database but im finding it had because of the want ant design table is set up. This is the code Note