Rewrite Stack implementation of ReactART using plain classes
instead of createClass
Andrew Clark committed
Mar 21, 2017 at 18:37 UTC
087fe88f20102454ec2581368dfb152abf3d7c20
1 file changed
+12
-14
src/renderers/art/ReactARTStack.js
+12
-14
@@ -170,12 +170,8 @@ const ContainerMixin = Object.assign({}, ReactMultiChild, {
170
// Surface is a React DOM Component, not an ART component. It serves as the
171
// entry point into the ART reconciler.
172
173
-const Surface = React.createClass({
174
- displayName: 'Surface',
175
-
176
- mixins: [ContainerMixin],
177
-
178
- componentDidMount: function() {
173
+class Surface extends React.Component {
174
+ componentDidMount() {
175
const domNode = ReactDOM.findDOMNode(this);
176
177
this.node = Mode.Surface(+this.props.width, +this.props.height, domNode);
@@ -189,9 +185,9 @@ const Surface = React.createClass({
185
ReactInstanceMap.get(this)._context,
186
);
187
ReactUpdates.ReactReconcileTransaction.release(transaction);
192
- },
188
+ }
189
194
- componentDidUpdate: function(oldProps) {
190
+ componentDidUpdate(oldProps) {
191
const node = this.node;
192
if (
193
this.props.width != oldProps.width || this.props.height != oldProps.height
@@ -220,13 +216,13 @@ const Surface = React.createClass({
216
if (node.render) {
217
node.render();
218
}
223
- },
219
+ }
220
225
- componentWillUnmount: function() {
221
+ componentWillUnmount() {
222
this.unmountChildren();
227
- },
223
+ }
224
229
- render: function() {
225
+ render() {
226
// This is going to be a placeholder because we don't know what it will
227
// actually resolve to because ART may render canvas, vml or svg tags here.
228
// We only allow a subset of properties since others might conflict with
@@ -246,8 +242,10 @@ const Surface = React.createClass({
242
title={props.title}
243
/>
244
);
249
- },
250
-});
245
+ }
246
+}
247
+Surface.displayName = 'Surface';
248
+Object.assign(Surface.prototype, ContainerMixin);
249
250
// Various nodes that can go into a surface
251