Installing React, my own app not displaying content


#1

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
Confused over this section

In app/components/App.js, write a component class. This component class can render whatever you want. Don’t forget to require React at the top of the file, and to set module.exports equal to your component class at the bottom of the file.

I might have added some extra lines in my App.js file, specifically:
var React = require(‘react’);
var ReactDOM = require(‘react-dom’);

What am I doing wrong? The goal is to display the image. http://localhost:8080/ is displaying fine, just no content on page.

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>

```

Replace this line with your code.

My App.js file:

var React = require('react');
var ReactDOM = require('react-dom');

import React from 'react';
import ReactDOM from 'react-dom';

function coinToss() {
  // This function will randomly return either 'heads' or 'tails'.
  return Math.random() < 0.5 ? 'heads' : 'tails';
}

const pics = {
  kitty: 'https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-kitty.jpg',
  doggy: 'https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-puppy.jpeg'
};
let img;

// if/else statement begins here:
if (coinToss() === 'heads') {
  img = <img src={pics.kitty} />
} else {
  img = <img src={pics.doggy} />
}

ReactDOM.render(
	img,
  document.getElementById('app')
);

and my index.js file:

var React = require('react');
var ReactDOM = require('react-dom');
var App = require('./components/App');

ReactDOM.render(
	<App />,
	document.getElementById('app')
);


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.