diff --git a/grunt/tasks/npm-react-addons.js b/grunt/tasks/npm-react-addons.js index c0818ff75fe..ead3ea333b5 100644 --- a/grunt/tasks/npm-react-addons.js +++ b/grunt/tasks/npm-react-addons.js @@ -11,12 +11,6 @@ var addons = { name: 'css-transition-group', docs: 'animation', }, - LinkedStateMixin: { - peerDependency: 'react', - module: 'LinkedStateMixin', - name: 'linked-state-mixin', - docs: 'two-way-binding-helpers', - }, Perf: { peerDependency: 'react-dom', module: 'ReactPerf', diff --git a/packages/react-linked-input/LinkedInput.js b/packages/react-linked-input/LinkedInput.js deleted file mode 100644 index 394056e0397..00000000000 --- a/packages/react-linked-input/LinkedInput.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -'use strict'; - -var React = require('react'); -var LinkedValueUtils = require('react-dom/lib/LinkedValueUtils'); - -class LinkedInput extends React.Component { - render() { - var newProps = Object.assign({}, this.props); - newProps.value = LinkedValueUtils.getValue(this.props); - newProps.checked = LinkedValueUtils.getChecked(this.props); - delete newProps.valueLink; - delete newProps.checkedLink; - return React.createElement('input', newProps); - } -} - -module.exports = LinkedInput; - diff --git a/packages/react-linked-input/README.md b/packages/react-linked-input/README.md deleted file mode 100644 index 3109ea7df12..00000000000 --- a/packages/react-linked-input/README.md +++ /dev/null @@ -1,11 +0,0 @@ -This component supports the ReactLink API (valueLink, etc) for input components. Support for ReactLink on DOM elements will be removed from React. This component may be used as a migration plan (so your code doesn't break in the next version of React) or may be used if you just like the ReactLink data binding semantics. However, this component is not maintained, so use at your own risk. - - -``` -var React = require('react'); -var ReactDOM = require('react-dom'); -var LinkedInput = require('react-linked-input'); - -var link = {value: 'boo', requestChange: function() {}}; -React.render(, container); -``` diff --git a/packages/react-linked-input/__test__/LinkedInput-test.js b/packages/react-linked-input/__test__/LinkedInput-test.js deleted file mode 100644 index fab7c3d5282..00000000000 --- a/packages/react-linked-input/__test__/LinkedInput-test.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @emails react-core - */ - -'use strict'; - - -describe('LinkedStateMixin', function() { - var LinkedInput; - var React; - var ReactDOM; - - beforeEach(function() { - LinkedInput = require('LinkedInput'); - React = require('React'); - ReactDOM = require('ReactDOM'); - }); - - it('should basically work', function() { - var container = document.createElement('div'); - var component = ReactDOM.render(, container); - var input = ReactDOM.findDOMNode(component); - expect(input.value).toBe('foo'); - ReactDOM.render(, container); - expect(input.value).toBe('boo'); - }); - - it('should throw', function() { - var container = document.createElement('div'); - var element = ; - expect(function() { - ReactDOM.render(element, container); - }).toThrow(); - }); -}); diff --git a/packages/react-linked-input/package.json b/packages/react-linked-input/package.json deleted file mode 100644 index 07f65db07c5..00000000000 --- a/packages/react-linked-input/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "react-linked-input", - "version": "1.0.1", - "description": "LinkedInput supports the ReactLink semantics", - "main": "LinkedInput.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/facebook/react.git" - }, - "keywords": [ - "react", - "linkedinput", - "input", - "linked", - "reactlink" - ], - "author": "", - "license": "BSD-3-Clause", - "peerDependencies": { - "react": "^15.0.1" - } -} diff --git a/scripts/fiber/tests-passing.txt b/scripts/fiber/tests-passing.txt index fa094df4a33..fdcfbdc8265 100644 --- a/scripts/fiber/tests-passing.txt +++ b/scripts/fiber/tests-passing.txt @@ -764,14 +764,6 @@ src/renderers/__tests__/ReactPerf-test.js * should not print errant warnings if portal throws in componentWillMount() * should not print errant warnings if portal throws in componentDidMount() -src/renderers/__tests__/ReactStateSetters-test.js -* createStateSetter should update state -* createStateKeySetter should update state -* createStateKeySetter is memoized -* createStateSetter should update state from mixin -* createStateKeySetter should update state with mixin -* createStateKeySetter is memoized with mixin - src/renderers/__tests__/ReactStatelessComponent-test.js * should render stateless component * should update stateless component diff --git a/scripts/release-manager/commands/utils/npm.js b/scripts/release-manager/commands/utils/npm.js index 5a9bf235fc0..e1ba2543bf8 100644 --- a/scripts/release-manager/commands/utils/npm.js +++ b/scripts/release-manager/commands/utils/npm.js @@ -5,7 +5,6 @@ const querystring = require('querystring'); const PACKAGES = [ 'react-addons-create-fragment', 'react-addons-css-transition-group', - 'react-addons-linked-state-mixin', 'react-addons-perf', 'react-addons-pure-render-mixin', 'react-addons-shallow-compare', diff --git a/src/addons/link/ReactStateSetters.js b/src/addons/link/ReactStateSetters.js deleted file mode 100644 index 977826d301a..00000000000 --- a/src/addons/link/ReactStateSetters.js +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule ReactStateSetters - */ - -'use strict'; - -var ReactStateSetters = { - /** - * Returns a function that calls the provided function, and uses the result - * of that to set the component's state. - * - * @param {ReactCompositeComponent} component - * @param {function} funcReturningState Returned callback uses this to - * determine how to update state. - * @return {function} callback that when invoked uses funcReturningState to - * determined the object literal to setState. - */ - createStateSetter: function(component, funcReturningState) { - return function(a, b, c, d, e, f) { - var partialState = funcReturningState.call(component, a, b, c, d, e, f); - if (partialState) { - component.setState(partialState); - } - }; - }, - - /** - * Returns a single-argument callback that can be used to update a single - * key in the component's state. - * - * Note: this is memoized function, which makes it inexpensive to call. - * - * @param {ReactCompositeComponent} component - * @param {string} key The key in the state that you should update. - * @return {function} callback of 1 argument which calls setState() with - * the provided keyName and callback argument. - */ - createStateKeySetter: function(component, key) { - // Memoize the setters. - var cache = component.__keySetters || (component.__keySetters = {}); - return cache[key] || (cache[key] = createStateKeySetter(component, key)); - }, -}; - -function createStateKeySetter(component, key) { - // Partial state is allocated outside of the function closure so it can be - // reused with every call, avoiding memory allocation when this function - // is called. - var partialState = {}; - return function stateKeySetter(value) { - partialState[key] = value; - component.setState(partialState); - }; -} - -ReactStateSetters.Mixin = { - /** - * Returns a function that calls the provided function, and uses the result - * of that to set the component's state. - * - * For example, these statements are equivalent: - * - * this.setState({x: 1}); - * this.createStateSetter(function(xValue) { - * return {x: xValue}; - * })(1); - * - * @param {function} funcReturningState Returned callback uses this to - * determine how to update state. - * @return {function} callback that when invoked uses funcReturningState to - * determined the object literal to setState. - */ - createStateSetter: function(funcReturningState) { - return ReactStateSetters.createStateSetter(this, funcReturningState); - }, - - /** - * Returns a single-argument callback that can be used to update a single - * key in the component's state. - * - * For example, these statements are equivalent: - * - * this.setState({x: 1}); - * this.createStateKeySetter('x')(1); - * - * Note: this is memoized function, which makes it inexpensive to call. - * - * @param {string} key The key in the state that you should update. - * @return {function} callback of 1 argument which calls setState() with - * the provided keyName and callback argument. - */ - createStateKeySetter: function(key) { - return ReactStateSetters.createStateKeySetter(this, key); - }, -}; - -module.exports = ReactStateSetters; diff --git a/src/renderers/__tests__/ReactStateSetters-test.js b/src/renderers/__tests__/ReactStateSetters-test.js deleted file mode 100644 index 34e13cafacb..00000000000 --- a/src/renderers/__tests__/ReactStateSetters-test.js +++ /dev/null @@ -1,152 +0,0 @@ -/** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @emails react-core - */ - -'use strict'; - -var React = require('React'); -var ReactStateSetters = require('ReactStateSetters'); -var ReactTestUtils = require('ReactTestUtils'); - -var TestComponent; -var TestComponentWithMixin; - -describe('ReactStateSetters', () => { - beforeEach(() => { - jest.resetModules(); - - TestComponent = class extends React.Component { - state = {foo: 'foo'}; - - render() { - return
; - } - }; - - TestComponentWithMixin = React.createClass({ - mixins: [ReactStateSetters.Mixin], - - getInitialState: function() { - return {foo: 'foo'}; - }, - - render: function() { - return
; - }, - }); - }); - - it('createStateSetter should update state', () => { - var instance = ; - instance = ReactTestUtils.renderIntoDocument(instance); - expect(instance.state).toEqual({foo: 'foo'}); - - var setter = ReactStateSetters.createStateSetter( - instance, - function(a, b, c) { - return { - foo: a + b + c, - bar: a * b * c, - }; - } - ); - expect(instance.state).toEqual({foo: 'foo'}); - - setter(1, 2, 3); - expect(instance.state).toEqual({foo: 6, bar: 6}); - - setter(10, 11, 12); - expect(instance.state).toEqual({foo: 33, bar: 1320}); - }); - - it('createStateKeySetter should update state', () => { - var instance = ; - instance = ReactTestUtils.renderIntoDocument(instance); - expect(instance.state).toEqual({foo: 'foo'}); - - var setter = ReactStateSetters.createStateKeySetter(instance, 'foo'); - - expect(instance.state).toEqual({foo: 'foo'}); - - setter('bar'); - expect(instance.state).toEqual({foo: 'bar'}); - - setter('baz'); - expect(instance.state).toEqual({foo: 'baz'}); - }); - - it('createStateKeySetter is memoized', () => { - var instance = ; - instance = ReactTestUtils.renderIntoDocument(instance); - expect(instance.state).toEqual({foo: 'foo'}); - - var foo1 = ReactStateSetters.createStateKeySetter(instance, 'foo'); - var bar1 = ReactStateSetters.createStateKeySetter(instance, 'bar'); - - var foo2 = ReactStateSetters.createStateKeySetter(instance, 'foo'); - var bar2 = ReactStateSetters.createStateKeySetter(instance, 'bar'); - - expect(foo2).toBe(foo1); - expect(bar2).toBe(bar1); - }); - - it('createStateSetter should update state from mixin', () => { - var instance = ; - instance = ReactTestUtils.renderIntoDocument(instance); - expect(instance.state).toEqual({foo: 'foo'}); - - var setter = instance.createStateSetter( - function(a, b, c) { - return { - foo: a + b + c, - bar: a * b * c, - }; - } - ); - expect(instance.state).toEqual({foo: 'foo'}); - - setter(1, 2, 3); - expect(instance.state).toEqual({foo: 6, bar: 6}); - - setter(10, 11, 12); - expect(instance.state).toEqual({foo: 33, bar: 1320}); - }); - - it('createStateKeySetter should update state with mixin', () => { - var instance = ; - instance = ReactTestUtils.renderIntoDocument(instance); - expect(instance.state).toEqual({foo: 'foo'}); - - var setter = instance.createStateKeySetter('foo'); - - expect(instance.state).toEqual({foo: 'foo'}); - - setter('bar'); - expect(instance.state).toEqual({foo: 'bar'}); - - setter('baz'); - expect(instance.state).toEqual({foo: 'baz'}); - }); - - it('createStateKeySetter is memoized with mixin', () => { - var instance = ; - instance = ReactTestUtils.renderIntoDocument(instance); - expect(instance.state).toEqual({foo: 'foo'}); - - var foo1 = instance.createStateKeySetter('foo'); - var bar1 = instance.createStateKeySetter('bar'); - - var foo2 = instance.createStateKeySetter('foo'); - var bar2 = instance.createStateKeySetter('bar'); - - expect(foo2).toBe(foo1); - expect(bar2).toBe(bar1); - }); -});