Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript React by Example Refining the App Refactor App Components: Solution

Jacob Herper
Jacob Herper
91,103 Points

Failed to compile after refactoring

Hi there,

I am wondering if I might have forgotten something in the React by Example course when refactoring the project. Now I get the following error and I can't figure our where the problem might lie:

      > Failed to compile
      > ./src/MainContent/index.js
      >   Line 12:  'totalInvited' is not defined       no-undef
      >   Line 13:  'numberAttending' is not defined    no-undef
      >   Line 14:  'numberUnconfirmed' is not defined  no-undef
import React from 'react';
import PropTypes from 'prop-types';

import ConfirmedFilter from './ConfirmedFilter';
import GuestList from './GuestList';
import Counter from './Counter';

const MainContent = props =>
  <div className="main">
    <ConfirmedFilter />

MainContent.propTypes = {
  toggleFilter: PropTypes.func.isRequired,
  isFiltered: PropTypes.bool.isRequired,
  totalInvited: PropTypes.number.isRequired,
  numberAttending: PropTypes.number.isRequired,
  numberUnconfirmed: PropTypes.number.isRequired,
  guests: PropTypes.array.isRequired,
  toggleConfirmationAt: PropTypes.func.isRequired,
  toggleEditingAt: PropTypes.func.isRequired,
  setNameAt: PropTypes.func.isRequired,
  removeGuestAt: PropTypes.func.isRequired,
  pendingGuest: PropTypes.string.isRequired

export default MainContent;

2 Answers

Torben Korb
.a{fill-rule:evenodd;}techdegree seal-36
Torben Korb
Front End Web Development Techdegree Graduate 90,635 Points

Hi Jacob,

try to pass the props to your components like props.totalInvited, props.numberAttending and so on. Those are declared in the context of main app and passed to your component here as props. So this is the way to access them.