This works best for me
<img
src={record.picture}
onError={({ currentTarget }) => {
currentTarget.onerror = null; // prevents looping
currentTarget.src="image_path_here";
}}
/>
More Related Contents:
- How to Protect website code PHP / JS? [closed]
- Understanding unique keys for array children in React.js
- What do these three dots in React do?
- React useEffect in depth / use of useEffect?
- Is useState synchronous? [duplicate]
- Problem in redirecting programmatically to a route in react router v6
- What happens when using this.setState multiple times in React component?
- React – changing an uncontrolled input
- What does npm install –legacy-peer-deps do exactly? When is it recommended / What’s a potential use case?
- Arrow functions and the use of parentheses () or {} or ({})
- ReactJS – Pass props with Redirect component
- React: how to load and render external html file?
- What does calling super() in a React constructor do?
- ES6 functions, arrow functions and ‘this’ in an ES6 class [duplicate]
- Use if statement in React JSX
- Can’t resolve module (not found) in React.js
- Using Matter.js to render to the DOM or React
- Rendering an array.map() in React
- Does new React Context API trigger re-renders?
- Playing sound in React.js
- Should we use useCallback in every function handler in React Functional Components
- React: Axios Network Error
- map function not working in React
- Why I receive blank page? React
- Detect scroll direction in React js
- React cannot read property map of undefined
- Exporting functions with reactjs and babel
- Next.js app folder: is there some “entry point”? A direct replacement for _app.tsx?
- State not getting updated when calling the related setState in React
- Enzyme simulate an onChange event