Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
111
rated 0 times [  117] [ 6]  / answers: 1 / hits: 35585  / 5 Years ago, wed, november 6, 2019, 12:00:00

I did add the folder structure so you could see.



How am I able to import image component into the card component ? Doesn't matter what path I try I get this error



./src/Components/Card/Card.js
Module not found: Can't resolve '../../Components/Image' in
'/Users/user/project/projecttest/src/Components/Card'


import React from 'react'
import styled, {ThemeProvider, css } from 'styled-components'
import Image from '../../Components/Image'


enter


More From » reactjs

 Answers
10

No, I see you importing: import Image from '../../Components/Image'. This mean you importing index of Image folder.



But in your code, you defining Image.js not index.js.
So, you have to import like this:



import Image from '../Image/Image' 


Or, you can rename file Image.js to index.js to shorten the code when import:



// rename Image.js to index.js
// then, import file:
import Image from '../Image'

[#51508] Tuesday, October 29, 2019, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kaleyv

Total Points: 259
Total Questions: 99
Total Answers: 107

Location: Saint Helena
Member since Tue, Nov 3, 2020
4 Years ago
;