score:1
Accepted answer
your item_id is set only one time and it is not changing at all. on first time when component load it will work but when you are doing second time you are passing new item id but component is not aware about this change hence not able to do anything.
try to create a function which fetch data. same function call it in componentdidmount. now when it is getting new props it is time to check . use componentdidupdate.
componentdidupdate(prevprops, prevstate){
if(prevprops.blogid != this.props.blogid){
this.setstate({
item_id: this.props.blogid
}, () => { call the function to get the data } )
}
}
Source: stackoverflow.com
Related Query
- React router renders component once after that only url changes
- React Router Dom & Firebase Auth: history.push changes url but does not render new component when called after firebase auth create account
- React JS, Router - component renders only after clicking a link
- How to unit test a React component that renders after fetch has finished?
- React Router V4: How to render a modal in the same screen changing only the url and then with that url, be able to rebuild the whole screen
- React router 4 `Link` component only changing the url and not updating the route
- React Js component rendering only once after state change
- React Router useHistory. History.push changes url but does not load component
- React Router Still Renders Previous Page after Routing to New Component
- React Router does not update component if url parameter changes
- Test React component (Jest & Enzyme) that renders differently after Ajax
- react router - make an ajax call only once per component
- React Router Link changes URL but doesn't render Component - Rest Countries API
- React router push only changes the url
- Component is not rendering However URL changes React Router v6
- URL changes but component is not render - React Router
- React router 4 - Why is my component only rendered on manually setting the url but not on clicking a Link with same url?
- React router changes url but not the component [SOLVED]
- Why React component only renders one item in array once but iterates through all items?
- React Router Question: why history.push changes url but doesn't update component
- Why is my react component not re rendering after dispatching an action that changes the redux store?
- react component detect changes only after a refresh
- React Router - URL changes but not Component
- why react router url changes but component does not load in my nested router app
- URL changes with React Router but component not rendering?
- How can I ensure that a React component is loaded only after some API call has been made?
- React router changes the url but not reload the component
- React router url changes correctly but component not being rendered from button component link
- Website only changes after reload - react router
- React Router Link Not Rendering the Component but changes the URL
More Query from same tag
- React - setTimeout inside promise flashes UI elements, randomly returns array undefined
- Change state if I choose other React Router?
- How to get Id after data is created in React (Next JS) and Apollo
- React Sortable Ordering Issue
- fetch() POST request to Express generates empty body {}
- theme does not recognize material-ui
- How to Pass a Variable from Child to Parent
- How to render different view when onClick button in ReactJS?
- How to user babel emotion macro in create-react-app?
- Styled component does not inherit styles when using "as" attribute
- Render component based on a variable - reactjs
- State not updating when using useContext
- Where to define props to access them in my React App?
- React-router-dom Protected Routes are not working
- Unit test in React requires construct or call signatures
- How to change color of specific elements in array
- How do I setState within React's recompose's lifecycle method?
- webpack:import global styles file into all components
- Updating RTK (redux toolkit) state using other state values
- How to set value to only one argument in the method using javascript?
- Handling AJAX Errors with Redux Form
- JSX expressions must have one parent element nextjs
- Embedding React into HTML-Page - Image URL's not working
- Check if selected date is greater than yesterday Typescript + React, momentjs
- How to stop permission when creating a new react app
- How to make a message disappear after a couple seconds elapse
- React sort a map function with two fields
- React - User-Defined JSX Components Not rendering
- react-google-charts click event not working
- React useForm get value from TextBox