0

I've been occasionally running into errors where working with ReactJS + JSX, the logfile being something like "react-with-addons.js:9729 Uncaught TypeError: type.toUpperCase is not a function". Searches of StackOverflow and especially the web suggest this is a common bugbear. One example, from someone wrapping a React classname in curly braces when such is not needed, is at: React error "Uncaught TypeError: type.toUpperCase is not a function" on a hello world app

I'm not completely sure how to take this beyond a statement that something is wrong, somewhere, and maybe a hint that it is a syntax error rather than, for instance, a logic error. None of my searching has turned up a smoking gun that will straightforwardly go from the toUpperCase error to a specific area to go to, or search for a particular kind of syntax error, or apply a particular heuristic or algorithm in searching your source. There are multiple parties that attest to similar errors, but so far no one I've read on the web has said, "Eureka!"

My code, very much in process, has a snapshot at http://pastebin.com/e7mG3mir . I'd like to fix this defect in my code specifically, but I'd like to know even more how to keep on chopping off and torching the heads of this Hydra-like class of bugs.

1 Answer 1

0

I'm not sure about an "in general" solution, but the question I referenced at React error "Uncaught TypeError: type.toUpperCase is not a function" on a hello world app was from wrongly handling JSX in a context where pure JavaScript is expected; in this case I gave a JSX tag where I should have given the class name.

The code I had was:

var pragmatometer = React.createElement(<Pragmatometer />, null);

The code I wanted was:

var pragmatometer = React.createElement(Pragmatometer, null);

So I'm not sure I have a general solution, but if (when) that error happens again, my first port of call will be any changes I have made where I was using (non-strictly-JavaScript) JSX syntax.

1

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.