John
John

Reputation: 733

Module not found: Error: Can't resolve child component

BookStore is the parent component and the SearchBooks is the child component. It compiles well but I get a runtime error that the child component is not resolved.

BookStore.tsx (parent component)

import { SearchBooks, SearchParameters } from 'ClientApp/components/SearchBooks';
...
export class BookStore extends React.Component<RouteComponentProps<{}>, {}> 
...
<SearchBooks searchForBooks={this.searchForBooks} />

SearchBooks.tsx

export class SearchBooks extends React.Component<IBookSearchProps> 
...

Routes.tsx

...
<Route path='/bookStore' component={BookStore} />

File Tree:

File tree

Error:

ERROR in ./ClientApp/components/BookStore.tsx Module not found: Error: Can't resolve 'ClientApp/components/SearchBooks' in '...\ClientApp\components' @ ./ClientApp/components/BookStore.tsx 12:0-63 @ ./ClientApp/routes.tsx @ ./ClientApp/boot.tsx @ multi react-hot-loader/patch event-source-polyfill webpack-hot-middleware/client?path=__webpack_hmr&dynamicPublicPath=true ./ClientApp/boot.tsx

Upvotes: 0

Views: 767

Answers (1)

Omar
Omar

Reputation: 3411

import { SearchBooks, SearchParameters } from './SearchBooks';

Same directory components and the file is SearchBooks.

Upvotes: 1

Related Questions