Codesandbox-client: create-reacte-app svg import support.

Created on 4 Oct 2018  路  4Comments  路  Source: codesandbox/codesandbox-client

馃悰 bug report

Description of the problem

Inability to load svg image in react component from a create-react-app sandbox.

How has this issue affected you? What are you trying to accomplish?

Getting errors when attempting to import an svg image, ex:
import calendarImg from 'svg-react-loader!./resources/calendar.svg';

Link to sandbox:

https://codesandbox.io/s/o5x2061zxy

Background:

So I've added svg-react-loader as a dependency to my project, and had found references to using the above import syntax when working with react-create-app based applications (so the project doesn't have to be ejected).

馃悰 Bug

All 4 comments

Showing the same issue -- looks like there may be an issue with the codesandbox server?

@CompuIves - any advice on how to get the console in the sandbox working again?

screen shot 2018-10-03 at 6 56 22 pm

Heyo! We have the svg loader built in in CRA v2, so this should work: https://codesandbox.io/s/5k8xxkxjpl.

Hopefully that fixes your issue!

well, that's much cleaner too. thanks!

What about importing SVGs or other image paths just using the import img from './img.svg' syntax?

I guess I'll make a new issue for this.

Edit: Done: https://github.com/codesandbox/codesandbox-client/issues/3825

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zocky picture zocky  路  3Comments

MarcelloTheArcane picture MarcelloTheArcane  路  3Comments

NataliaTepluhina picture NataliaTepluhina  路  3Comments

Haroenv picture Haroenv  路  3Comments

Haroenv picture Haroenv  路  3Comments