@@ -46,56 +46,61 @@ def self.create_native_react_class(type)
46
46
render_fn = ( type . method_defined? :_render_wrapper ) ? :_render_wrapper : :render
47
47
# this was hashing type.to_s, not sure why but .to_s does not work as it Foo::Bar::View.to_s just returns "View"
48
48
@@component_classes [ type ] ||= %x{
49
- React.createClass({
50
- displayName: #{ type . name } ,
51
- propTypes: #{ type . respond_to? ( :prop_types ) ? type . prop_types . to_n : `{}` } ,
52
- getDefaultProps: function(){
49
+ class extends React.Component {
50
+ constructor(props) {
51
+ super(props);
52
+ this.displayName = #{ type . name } ;
53
+ this.mixins = #{ type . respond_to? ( :native_mixins ) ? type . native_mixins : `[]` } ;
54
+ this.statics = #{ type . respond_to? ( :static_call_backs ) ? type . static_call_backs . to_n : `{}` } ;
55
+ }
56
+ static get defaultProps() {
53
57
return #{ type . respond_to? ( :default_props ) ? type . default_props . to_n : `{}` } ;
54
- },
55
- mixins: #{ type . respond_to? ( :native_mixins ) ? type . native_mixins : `[]` } ,
56
- statics: #{ type . respond_to? ( :static_call_backs ) ? type . static_call_backs . to_n : `{}` } ,
57
- componentWillMount: function() {
58
+ }
59
+ /* static get propTypes() {
60
+ return #{ type . respond_to? ( :prop_types ) ? type . prop_types . to_n : `{}` } ;
61
+ } */
62
+ componentWillMount() {
58
63
var instance = this._getOpalInstance.apply(this);
59
64
return #{ `instance` . component_will_mount if type . method_defined? :component_will_mount } ;
60
- },
61
- componentDidMount: function () {
65
+ }
66
+ componentDidMount() {
62
67
var instance = this._getOpalInstance.apply(this);
63
68
return #{ `instance` . component_did_mount if type . method_defined? :component_did_mount } ;
64
- },
65
- componentWillReceiveProps: function (next_props) {
69
+ }
70
+ componentWillReceiveProps(next_props) {
66
71
var instance = this._getOpalInstance.apply(this);
67
72
return #{ `instance` . component_will_receive_props ( Hash . new ( `next_props` ) ) if type . method_defined? :component_will_receive_props } ;
68
- },
69
- shouldComponentUpdate: function (next_props, next_state) {
73
+ }
74
+ shouldComponentUpdate(next_props, next_state) {
70
75
var instance = this._getOpalInstance.apply(this);
71
76
return #{ `instance` . should_component_update? ( Hash . new ( `next_props` ) , Hash . new ( `next_state` ) ) if type . method_defined? :should_component_update? } ;
72
- },
73
- componentWillUpdate: function (next_props, next_state) {
77
+ }
78
+ componentWillUpdate(next_props, next_state) {
74
79
var instance = this._getOpalInstance.apply(this);
75
80
return #{ `instance` . component_will_update ( Hash . new ( `next_props` ) , Hash . new ( `next_state` ) ) if type . method_defined? :component_will_update } ;
76
- },
77
- componentDidUpdate: function (prev_props, prev_state) {
81
+ }
82
+ componentDidUpdate(prev_props, prev_state) {
78
83
var instance = this._getOpalInstance.apply(this);
79
84
return #{ `instance` . component_did_update ( Hash . new ( `prev_props` ) , Hash . new ( `prev_state` ) ) if type . method_defined? :component_did_update } ;
80
- },
81
- componentWillUnmount: function () {
85
+ }
86
+ componentWillUnmount() {
82
87
var instance = this._getOpalInstance.apply(this);
83
88
return #{ `instance` . component_will_unmount if type . method_defined? :component_will_unmount } ;
84
- },
85
- _getOpalInstance: function () {
89
+ }
90
+ _getOpalInstance() {
86
91
if (this.__opalInstance == undefined) {
87
92
var instance = #{ type . new ( `this` ) } ;
88
93
} else {
89
94
var instance = this.__opalInstance;
90
95
}
91
96
this.__opalInstance = instance;
92
97
return instance;
93
- },
94
- render: function () {
98
+ }
99
+ render() {
95
100
var instance = this._getOpalInstance.apply(this);
96
101
return #{ `instance` . send ( render_fn ) . to_n } ;
97
102
}
98
- })
103
+ }
99
104
}
100
105
end
101
106
0 commit comments