Im trying to import useHistory from react-router-dom but it keeps giving me the error ‘react-router-dom’ does not contain an export named ‘useHistory’. React-router-dom’s version is 4.3.1 and i’ve tried updating (in case there was an updated version) but every time i do npm install react-router-dom it always just installs 4.3.1 It updated react-router from 4.3.1 to 5.2.0 just fine so
Tag: reactjs
Material-UI Select doesn’t update after onChange
I’ve seen this problem about all around the web but nothing could come short of giving me a valid explanation. I’m using Material-UI Select and the good ol’ setState(…) from React (not hooks though) My component is composed essentially of those lines : And my problem is that my Select component dosen’t update its value after selecting another option. So
How to convert a javascript array of Objects from one format to another format?
I have an array of objects and want to convert it from one format to another format. the initial array looks like: how to convert it to a format like this? any help please? Answer You can populate an objected keyed off the value categories and add the relevant data.
Adding a TextInput inside a Modal at React Native
Hi guys I am working on a React Native Project. I’m a newbie to programming/React Native. I don’t know how to put a textinput box in my modal on App.js. want to create an email textinput inside this modal Need some guidance and instructions. Help! https://reactnative.dev/docs/textinput this is the example I am following. I am pasting it inside my app.js
How to listen to external variable changes in React
Hope you’re doing well 🙂 I’ve an “auth.js” file, with an aysnc function to get the userId and then store it in session storage. Here it is: Then I access this variable in all components that need it, in order to make other requests. Example in App.js: The problem is that, in the first render, the userId comes null (obviously)
Why won’t setMatrix([…matrix, [[x][y]]]) work?
I want to add the coordinates x and y (from the loop) to the state (matrix) like you can see in my example but it won’t work. Can someone help me? Answer The problem is in expression [x][y] which evaluates to undefined. [x] defines an array containing one element x [x][y] tries to index the [x] array, taking y-th element.
How to make React Redux async action return a promise?
I have a redux action function that returns a promise. Inside that function body, there is another async function that returns a callback when it finished the call. Then I call this function in another place chaining it with .then() but when debugging it in the browser with breakpoints, the promise function exists after the first two lines of code
(React and Redux) Problem with adding items to the shopping cart
I am following a tutorial, where we are building a shopping cart, which is still unfinished, but I would like to solve this problem before continuing in the tutorial. The thing is, that when I try to add any item to the cart, the cart is still saying me, that my shopping cart is empty. You can notice in the
Forwarding props from parent to child component
I have 2 components list of posts and when clicking on link on post card i’m entering into post. I can’t access props.postDetails in child component. When I console log the props, I have {history: {…}, location: {…}, match: {…}, staticContext: undefined} only this without props.postDetails. Can somebody help? Code for parent component is: Code for child component: Answer Issue
What is the difference between react: class vs function App()?
When I download a react project, my default in App.js is : function App() However, a lot of YouTube tutorials uses: class App extends React.Component { Is there a difference between the two? Is one …