I trying to fetch data of an object (in this example from https://api.themoviedb.org/3/movie/459151?api_key=f13446aa3541ebd88cf65b91f6932c5b) and I’m trying to assign it to state movie. However, when I console it out, it has value undefined (actually, it is consoled out twice, firstly with default values of state and secondly as undefined). How to solve it? Thanks Answer As it seems in the API
Tag: reactjs
Render specific react component based on the URL
App.js Home.js This works perfectly as I want to render the Feed or Search component depending on the URL. But, I want to know is it okay to use location.pathname or is there any better alternative? Answer You could do something like: App.js Home.js This allows you to abstract away the Home component’s dependency on any routing mechanism, and simply
Receiving ERROR #98123 after gatsby develop
I’m receiving this error after I run gatsby develop. I have tried following the steps from gatsby.com Not sure the reason for this error. I have tried gatsby clean, removing files that were giving errors, and utilizing google. I have posted on GitHub and discord, but have not received any updates yet. Any assistance is appreciated. Answer It looks like
onClick of button triggering all the components to open – Reactjs
I implemented a Card component and basically generating a bunch of cards on some input data. I binded a setter function on button click on every card which basically expands and collapse it. Even after putting unique keys to the div is sort of triggering all the cards to open at once. Here is the code piece: Answer Create a
Accessing error from react-hook-form using reactstrap
I created a form with reactstrap and react-hook-form. Why are my errors not displaying? Dummy section which renders text input: Text input with error: Submit Button Thanks. Code Sandbox Answer @jamfie, you are using different useForm for each component. Your form need to have the same instance, you can do that by using useformcontext or by passing props to components.
destructuring props in component getting different result
New to react world, trying to learn destructuring, have been reading about it but stuck here, if i do it like this function MList({action}) { // const data = [action];} i am just getting ‘cameras’. So how to destructure and get same result as with props below this is Mcard.js: This is inside MList komponent: i want to destructure this
Routing not working in a react app with webpack
I’m trying to create a react app with webpack which has some routing as well. The routing works but when I go to a specific route and reload the page, it gives an error cannot get /about As mentioned in this answer, adding fixes the issue when its being run locally, but as soon as I deploy it, I get
css different style to specific div created by map
I am creating a list of divs, which was created with map. this renders a list of divs, and I was able to change each div background, when hover, like this: I wish to be able to click on a div, and change its background color to white. everything I try will change the background of all the 10 divs
How to get parent props from child composition component React
My goal is reduce every letter prop from child (Palata) component, how can i achieve this ? index.js Block.js there is a question, how to pass Block component letter prop as data to Palata component or Palata.js or how to get parent letter prop from inside Palata component? Thanks for help! Answer You can’t access props of parent component. Also
How do you pass state variables between two separate functional components in React Native?
} I don’t know react native that well and I need help with the code writing itself. I tried using useContext() but it was written in react and I’m a beginner so I don’t really understand how to implement it. Also, there are no parent functions for this piece of code and both functions are in the same file. I