ShakaCode | ShakaCode Blog | Rails On Maui Blog | Rails | ReactJs | JavaScript | Webpack | Productivity |

Uncaught TypeError: object is not a function react router


#1

If you’ve ever gotten this mysterious message in the console:

Uncaught TypeError: type.toUpperCase is not a function

Or

Uncaught TypeError: object is not a function react router...

Chances are that you may have forgotten the line with export in one of your react components. When that happens, the import just gets an empty object.

I had done exactly that, by forgetting to put in the final line with the export:

import React from 'react';

const AppDefault = React.createClass({
  displayName: 'AppDefault',
  statics: {
    willTransitionTo(transition) {
      transition.redirect('instructions');
    }
  },

  render() {
    return <div/>;
  }
});

export default AppDefault;