Michael Roberts Michael Roberts - 1 year ago 102
React JSX Question

Replacing a React.createClass with extends React.Component

Facebook has suggested the future removal of React.createClass completely in favour of ES6 classes. I'm now beginning to go through my react.js classes and replace them with the now accepted

class MyClass extends React.Component
syntax. However, I don't think I'm quite there yet on some things. I have coded the following API mount and gulp doesn't seem to like this particular module when loading:
Cannot find module '.components/ticker-trader' from '/.../src'

My particular class is outlined as:

import React, { Component, PropTypes } from 'react';

class TickerTrader extends React.Component {
constructor(props) {
this.state = {


componentDidMount() {
$.get("api_url", function(data) {

render() {
return (

export default TickerTrader;

Could anyone outline where exactly this has gone wrong...I'm sure it is something simplisitic. I have attempted to fix this by using the documentation but I don't seem to be getting anywhere...

Answer Source

Check your file paths.

Cannot find module '.components/ticker-trader' from '/.../src'

That looks wrong.

Instead of .components/ticker-trader it more than likely should be looking for ./components/ticker-trader.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download