UNPKG

1.32 kBJavaScriptView Raw
1/**
2 * Copyright 2013-present, Facebook, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
8 *
9 */
10
11'use strict';
12
13var _assign = require('object-assign');
14
15var ReactComponent = require('./ReactComponent');
16var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
17
18var emptyObject = require('fbjs/lib/emptyObject');
19
20/**
21 * Base class helpers for the updating state of a component.
22 */
23function ReactPureComponent(props, context, updater) {
24 // Duplicated from ReactComponent.
25 this.props = props;
26 this.context = context;
27 this.refs = emptyObject;
28 // We initialize the default updater but the real one gets injected by the
29 // renderer.
30 this.updater = updater || ReactNoopUpdateQueue;
31}
32
33function ComponentDummy() {}
34ComponentDummy.prototype = ReactComponent.prototype;
35ReactPureComponent.prototype = new ComponentDummy();
36ReactPureComponent.prototype.constructor = ReactPureComponent;
37// Avoid an extra prototype jump for these methods.
38_assign(ReactPureComponent.prototype, ReactComponent.prototype);
39ReactPureComponent.prototype.isPureReactComponent = true;
40
41module.exports = ReactPureComponent;
\No newline at end of file