score:0
Accepted answer
i don't think you are experiencing problems because of the way you are loading your image (i tried @michael's answer and it did not load the images for me, while your code worked.)
here is the minimal code i wrote to check your solution and it works perfectly on my end. maybe try editing your post to add a bit more context to your question.
score:0
you should import images in the parent component and then pass them to child components like a component.
try this:
import a1old from '../img/a1-old.png'
import a2old from '../img/a2-old.png'
class board extends react.component {
constructor(props) {
super(props);
this.state = {
squares: [
{ title: "a1", image: <a1old /> },
{ title: "a2", image: <a2old /> },
]
};
}
...
Source: stackoverflow.com
Related Query
- How can i get array of object from this data for state and count in reactjs
- How to pass multiple state through link in ReactJS
- How to make React.js fetch data from api as state and pass this state data from its parent to child component
- how to set react parent component state by a async function and then pass this state to child as props?
- How to pass state from parent Component to child component in route (react-route-dom) reactjs
- Need Reactjs help on how to properly pass this function from the parent to child button component
- How can i pass a boolean state in reactjs with typescript
- How to pass state value from one class to another in Reactjs
- How to pass the value of AceEditor to the component state using the onClick of a button? ReactJS
- How to pass props or state from parent to child react in this format
- reactJS how to pass state when going to another URL? (clicking "New" on navbar that goes to Submit form)
- How do you pass an image from the root component to a child component using state variables in React?
- React state update error whenever i open someone's image, and image not redering too. How can I fix this error
- How to pass the changed state from child component to its parent in ReactJS
- How to pass app state in ReactJS to the backend?
- How do I change the value of this component everytime I pass it in? ES6, reactJS
- ReactJS Classes How to pass State from Child Component to its Parent?
- How to pass a state variable as a string in this case?
- variable not working with the createContext, how should i pass this trough the state
- ReactJS - How to pass state data and functions from one functional component to other component?
- How to pass image to this.state in reactJS
- How to retain and pass the new state values to another router component in ReactJS
- How do I pass state through React_router?
- How to pass state back to parent in React?
- React - how to pass state to another component
- ReactJS - how to pass "global" data to deeply nested child components?
- How to detect when a image is loaded, that is provided via props, and change state in React?
- How to display a image selected from input type = file in reactJS
- How to avoid 'children with same key' when replacing state in ReactJs component
- React router and this.props.children - how to pass state to this.props.children
More Query from same tag
- Firebase + React - Not changing my state
- Input Text unfocuses after each character is typed in, but it seems to be a target issue within React
- Change date format in antd <DatePicker />
- How to store firestore collection reference and add as field for different collection in firebase?
- How to delete a specific row in Material UI DataGrid (Reactjs)
- React's useSelector with array of objects
- Validation accept only two specific fields the selector with yup
- SVG scale animation slow on iOS
- Socket.io - React: How to display the users connected in a room?
- Concat prop value with string in styled-component
- React js Objects are not valid as a React child
- React: Toggle function in child component not working as expected
- Cannot read property 'modalIsOpen' of undefined
- How to render component only once in React Native
- React native flexbox - how to do percentages || columns || responsive || grid etc
- Same session in multiple tabs and when a user logs in any tab and if they navigate in a new tab of same browser they must already be logged in
- How to give next js app build to the client
- React + Sails + Socket.io
- Individual component exports with Rollup instead of one massive index.js file?
- In jest/enzyme, how do you simulate a click on an element with eventListener bound by [element].addEventListener (not window.addEventListener)?
- npx create-react-app not working "Must use import to load ES Module:"
- React useRef : Null (Cannot read property 'children' of null)
- How to use Material UI TreeView with Recursive TreeItem Component with added state
- Accessing to the NextJs Link href property from children component
- What is prevState in ReactJS?
- React boolean components: If and IfElse
- How to redirect to a route from an external function in ReactJS
- Is there a benefit in React useEffect to resolving promises like this?
- Cannot read property of undefined image within Gatsby, Contentful and Graphql?
- Sprite sometimes doesn't load in Phaser game