Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load SVG file: {path} #10

Closed
TravisSiebenhaar opened this issue Nov 23, 2016 · 2 comments
Closed

Unable to load SVG file: {path} #10

TravisSiebenhaar opened this issue Nov 23, 2016 · 2 comments

Comments

@TravisSiebenhaar
Copy link

TravisSiebenhaar commented Nov 23, 2016

I have installed react-svg and I am trying to import an svg image. Here is my file:

import React, {PropTypes} from 'react';
import styles from '../common/contentBoxStyles';
import ReactSVG from 'react-svg';

const WeatherReport = ({report}) => {
  return (
  	<div style={styles.body} className="row">
  		<div style={styles.weatherBoxContainer}>
  			<div className="col-sm-2 col-md-offset-1" style={styles.weatherBoxContainer.weatherCard}>
  				<div style={styles.weatherBoxContainer.weatherReport}>
  					<ReactSVG path={'../common/svg/O1n.svg'} callback={(svg) => console.log(svg)} />
  					<div className="row" style={styles.weatherBoxContainer.temps}>
  						<div className="col-sm-4">
  							<div>{Math.floor(report.main.temp_max)}°</div>
  							<div>{Math.floor(report.main.temp_min)}°</div>
  						</div>
  						<div className="col-sm-8" style={styles.weatherBoxContainer.currentTemp}>
  							{Math.floor(report.main.temp)}°
  						</div>
  					</div>
  				</div>
  				CA
  			</div>
  			<div className="col-sm-2" style={styles.weatherBoxContainer.weatherCard}>
  				<div style={styles.weatherBoxContainer.weatherReport}>
  					Report
  				</div>
  				UT
  			</div>
  			<div className="col-sm-2" style={styles.weatherBoxContainer.weatherCard}>
  				<div style={styles.weatherBoxContainer.weatherReport}>
  					Report
  				</div>
  				MN
  			</div>
  			<div className="col-sm-2" style={styles.weatherBoxContainer.weatherCard}>
  				<div style={styles.weatherBoxContainer.weatherReport}>
  					Report
  				</div>
  				DC
  			</div>
  			<div className="col-sm-2" style={styles.weatherBoxContainer.weatherCard}>
  				<div style={styles.weatherBoxContainer.weatherReport}>
  					Report
  				</div>
  				NY
  			</div>
  		</div>
  	</div>
  );
};

WeatherReport.propTypes = {
  report: PropTypes.object
};

export default WeatherReport;

Here is my file structure:

src
|_ _components
|    |_ _dashboard
|    |    |_ _WeatherReport.js
|    |_ _common
|         |_ _svg
|              |_ _O1n.svg

Console reads out:
Unable to load SVG file: ../common/svg/O1n.svg
undefined

I have installed through npm w/o issues:
svg-injector
react-svg

What am I missing here?

@tanem
Copy link
Owner

tanem commented Dec 18, 2016

@Nappstir see #7. Sounds like you need to be running a local webserver.

@tanem
Copy link
Owner

tanem commented Dec 30, 2016

Closing due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants