JavaScript How to implement “normal” ES5 prototypal inheritance in React?

I am under the impression that ES6 classes are basically a syntactic sugar around the ES5 objects system. As I am trying to run React without a transpiler, I figured that I could use just use the old syntax for defining object "classes" that "inherit" from React.Component.

    var Board = function(props, state) {
        var instance = {};

        instance.props = props;
        instance.context = state;

        return(instance);           
    };

    Board.prototype = Object.create(React.Component.prototype);

    Board.prototype.render = function() {
        return(
            // ...stuff
        )               
    };

But that does not work!

react.js:20478 Warning: Board(...): No `render` method found on the returned component instance: you may have forgotten to define `render`
react.js:6690 Uncaught TypeError: inst.render is not a function(…)

I found alternatives in this gist, and the following works:

    var Board = function(props, state) {
        var instance = Object.create(React.Component.prototype);

        instance.props = props;
        instance.context = state;

        instance.prototype.render = function() {
            return(
                // ...stuff
            )               
        };

        return(instance);           
    };

I have also found out that I can use the React.createClass helper.

But I still would like to understand why React would not handle classes defined in such a common way. It seems to me that ES6 classes are instanciated before being used. I see no reason why ES5-style classes would not be instanciated as well, with similar results.

Answer:1

Is there a way to keep some sort of internal state while writing a curried function? For example, let's say I want to write a curried function that takes into account the number of times the function ...

Is there a way to keep some sort of internal state while writing a curried function? For example, let's say I want to write a curried function that takes into account the number of times the function ...

I am figuring out of i can make something like Google analytics script. They work with javascript to capture data and send it to an given URL. But i want it to do without ajax or REST API. What i ...

I am figuring out of i can make something like Google analytics script. They work with javascript to capture data and send it to an given URL. But i want it to do without ajax or REST API. What i ...

I am using this code to let user draw circles or images drawingManager = new google.maps.drawing.DrawingManager({ drawingMode: null, drawingControlOptions: { ...

I am using this code to let user draw circles or images drawingManager = new google.maps.drawing.DrawingManager({ drawingMode: null, drawingControlOptions: { ...

  1. wpf custom drawing control
  2. custom drawing treeview control
  3. custom control not drawing

Why is the result of the following code 1 and not 10? Why doesn't the function bar() change the value, even though there is a return statement. var foo = 1; function bar() { foo = 10; return; ...

Why is the result of the following code 1 and not 10? Why doesn't the function bar() change the value, even though there is a return statement. var foo = 1; function bar() { foo = 10; return; ...

  1. what function creates the frame that holds the drawing
  2. what function creates a circle
  3. what function creates a parabola
  4. what creates a function
  5. what statement creates a function in python
  6. what statement creates a function