react / react-0.13.3 / examples / basic-commonjs / node_modules / reactify / node_modules / react-tools / src / core / ReactDoNotBindDeprecated.js
81152 views/**1* Copyright 2013-2014, Facebook, Inc.2* All rights reserved.3*4* This source code is licensed under the BSD-style license found in the5* LICENSE file in the root directory of this source tree. An additional grant6* of patent rights can be found in the PATENTS file in the same directory.7*8* @providesModule ReactDoNotBindDeprecated9*/1011"use strict";1213var ReactDoNotBindDeprecated = {14/**15* Marks the method for not being automatically bound on component mounting. A16* couple of reasons you might want to use this:17*18* - Automatically supporting the previous behavior in components that were19* built with previous versions of React.20* - Tuning performance, by avoiding binding on initial render for methods21* that are always invoked while being preceded by `this.`. Such binds are22* unnecessary.23*24* React.createClass({25* handleClick: ReactDoNotBindDeprecated.doNotBind(function() {26* alert(this.setState); // undefined!27* }),28* render: function() {29* return <a onClick={this.handleClick}>Jump</a>;30* }31* });32*33* @param {function} method Method to avoid automatically binding.34* @public35*/36doNotBind: function(method) {37method.__reactDontBind = true; // Mutating38return method;39}40};4142module.exports = ReactDoNotBindDeprecated;434445