score:0
you can do this
<img src={require(${this.props.yourpropname})} alt="my image"/>
and take any name as a prop in the tag and then pass it!!
score:3
did you try the other way around? i am assuming you will import the images in your parent component. also the reason you are getting that error is probably because your parent component and child component are not in the same directory. the image path is ./cube
relative to parent which means it resides in the same directory as parent.
parent component
<inputsection ref="inputs" imd={this.getdata} imageuri={require(this.state.imageurl)} />
child component
<img ref="image" src={this.props.imageuri} />
Source: stackoverflow.com
Related Query
- How to pass image url as prop in React
- React - How to pass image url from data map to component?
- React styled components pass image url prop to display different image per page?
- React - How to pass props to a component passed as prop
- using css modules in react how can I pass a className as a prop to a component
- How to pass a React component as a prop
- How do I pass a Prop to a Navigation Screen Component - React Native
- How to pass the React Router location prop to a component?
- How to dynamically decide to pass a prop to a react component or not?
- How pass React prop to CSS
- How can i pass URL parameter to react js widget
- How do you pass a prop to all react routes? (Change title dynamically)
- How can I pass a prop by child index in React
- Express, how to pass long url path to react router?
- How to use a prop to form an image url
- how to pass prop server side react
- How to pass React Component prop to child function using {children}?
- How to pass function from FUNCTIONAL to CLASS component and access it outside of render( without prop ), using context in react js?
- How do I pass a prop to a react component yet not update that prop in the child when parent changes?
- How to pass image source as Property in React JS?
- How to pass id in path url as component property in react router v6
- How to pass an array in query parameter url react
- How to pass in prop from react-router / url to graphql query?
- How can I pass a function as a prop to a React component using react-router <Redirect />?
- How to pass an object as a prop in React using typescript?
- How to pass a function as a prop to React function component?
- How can I pass Apollo data and React Router 4 url params to my components
- React Redux: How to pass specific object prop from store to child component?
- How do I pass a component as a prop in React and Typescript?
- How can I pass image url from parent component to child component via props [REACT.JS]
More Query from same tag
- How to provide a ref to a child element
- Material UI Snackbar + Progress
- React context returns promise
- material UI popover - position on small screen
- Error: Cyclic dependency with Yup Validation
- How to solve the error 'Warning: React.createElement: type should not be null, undefined in React?
- Coordinates array from PolylineMeasure plugin (react leaflet)
- copytoclip board is not working with input filed having type hidden in react
- getting information from url
- How to use a custom React hook to make a POST or DELETE request with Axios
- Testing for text broken up by multiple elements in React Testing Library
- How to toggle setInterval in a child via state that was passed from parent component as a prop
- Superclass constructor invocation should be in constructor body
- Adding a React Component within dangerouslySetInnerHtml or similar
- Render multiple SVG icons dynamically
- ReactJS dynamically adding onClick event
- How can I get the object which has been changed and also the new changed value when Selecting options from the drop down
- SVG with React via svgr failing
- React component using jQuery without require - jest unit tests
- Unable to access Children from json , react-redux
- Animating exit of an element in React Motion (which receives these elements from a parent component)
- ReactJS - Does render get called any time "setState" is called?
- Object navigator.mediaDevices is not accessible on mobile chrome browser
- React inner div height 100%
- React testing library: Cannot find module declared in .d.ts
- Declaring React Routes in a separate file and Importing
- Setting children in defaultProps
- couldn't get to detail page for each restaurant from my Restaurant list
- Use NProgress with "React.lazy"
- How to set up redux-persist with middlewares properly?