How to make svg react component imports from external module working with create-react-app? #10898
Unanswered
soullivaneuh
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context
In order to make some code parts re-usable accross many react project, I have the following project structure:
@foo/design
: Containing design stuff such as raw svg images@foo/ui
: A react library base on Create React App for common component@foo/project
: A final CRA project usingfoo/ui
The library
The
foo/ui
library export some a component that import a svg image from@foo/design
:This component works flawlessly on the related Storybook instance of
@foo/ui
and is compiled usingtsc
like this:Here is also the related
tsconfig.json
file:The project import
On
@foo/project
, I added the@foo/ui
dependency, installing the@foo/design
package as well (required by@foo/ui
).I use my component that way:
But this produces the following error:
However, if I copy/past the svg import line from
MyComponent.js
directly on my root app component:This works and the svg appears as expected.
Here is also the CRA project related
tsconfig.json
file:Why the
ReactComponent
CRA import is not working when it's done from my imported library? What is the simplest way to solve this problem as@foo/ui
is only use internally?Thanks
Note: Initially posted on Stack Overflow: https://stackoverflow.com/q/67320996/1731473
Beta Was this translation helpful? Give feedback.
All reactions