0

i am a react newbie, and every routing example i have found routes to components defined as const, but when using a component class with react router v4 the following error is thrown:

"TypeError: Cannot read property 'apply' of undefined at new About (wuwemek.js:34:70) ..."

jsbin example

in the following example, routing to {Home} works fine, but routing to {About} throws the above error. relevant code below - please let me know if you need to see more:

var { BrowserRouter, Route, Link } = ReactRouterDOM;

const Home = () => <p>home</p>

class About extends React.Component {
  render() {
    return (<div>about</div>)
  }
}

<Link to="/">home</Link>
<Link to="/about">about</Link>

<Route exact path="/" component={Home}/>
<Route path="/about" component={About}/>

1 Answer 1

1

There is nothing wrong with your code. Your jsbin's setting is incorrect. You should set it as JSX (React), not ES6/ Babel.

Sign up to request clarification or add additional context in comments.

1 Comment

holy moly you are right - what a knucklehead i am! thank you so much for pointing this out, and in a kindly manner. : )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.