diff --git a/js/components/ascribe_buttons/acl_button_list.js b/js/components/ascribe_buttons/acl_button_list.js index 75add937..dd22bf50 100644 --- a/js/components/ascribe_buttons/acl_button_list.js +++ b/js/components/ascribe_buttons/acl_button_list.js @@ -1,6 +1,6 @@ 'use strict'; -import React from 'react/addons'; +import React from 'react'; import ConsignButton from './acls/consign_button'; import EmailButton from './acls/email_button'; @@ -61,7 +61,7 @@ let AclButtonList = React.createClass({ const { buttonListSize } = this.state; return React.Children.map(children, (child) => { - return React.addons.cloneWithProps(child, { buttonListSize }); + return React.cloneElement(child, { buttonListSize }); }); }, diff --git a/js/components/ascribe_buttons/form_submit_button.js b/js/components/ascribe_buttons/form_submit_button.js index c0335a4b..100ad1b1 100644 --- a/js/components/ascribe_buttons/form_submit_button.js +++ b/js/components/ascribe_buttons/form_submit_button.js @@ -1,6 +1,7 @@ 'use strict'; -import React from 'react/addons'; +import React from 'react'; +import update from 'react-addons-update'; const { string, object } = React.PropTypes; @@ -30,7 +31,7 @@ const FormSubmitButton = React.createClass({ }, setReadyStateForKey(key, state) { - const readyStates = React.addons.update(this.state.readyStates, { [key]: { $set: state } }); + const readyStates = update(this.state.readyStates, { [key]: { $set: state } }); this.setState({ readyStates }); }, diff --git a/js/components/ascribe_forms/form.js b/js/components/ascribe_forms/form.js index 688d5428..378f024d 100644 --- a/js/components/ascribe_forms/form.js +++ b/js/components/ascribe_forms/form.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import ReactAddons from 'react/addons'; import classNames from 'classnames'; @@ -257,7 +256,7 @@ let Form = React.createClass({ }, renderChildren() { - return ReactAddons.Children.map(this.props.children, (child, i) => { + return React.Children.map(this.props.children, (child, i) => { if (child) { // Since refs will be overwritten by this functions return statement, // we still want to be able to define refs for nested `Form` or `Property` diff --git a/js/components/ascribe_forms/input_contract_agreement_checkbox.js b/js/components/ascribe_forms/input_contract_agreement_checkbox.js index f4d14bd9..1e1411db 100644 --- a/js/components/ascribe_forms/input_contract_agreement_checkbox.js +++ b/js/components/ascribe_forms/input_contract_agreement_checkbox.js @@ -1,6 +1,7 @@ 'use strict'; -import React from 'react/addons'; +import React from 'react'; +import update from 'react-addons-update'; import InputCheckbox from './input_checkbox'; @@ -101,7 +102,7 @@ const InputContractAgreementCheckbox = React.createClass({ // so the parent `Property` is able to get the correct value of this component // when the `Form` queries it. this.setState({ - value: React.addons.update(this.state.value, { + value: update(this.state.value, { terms: { $set: event.target.value } }) }); diff --git a/js/components/ascribe_forms/property.js b/js/components/ascribe_forms/property.js index b8b90400..9a495ef6 100644 --- a/js/components/ascribe_forms/property.js +++ b/js/components/ascribe_forms/property.js @@ -1,14 +1,11 @@ 'use strict'; import React from 'react'; -import ReactAddons from 'react/addons'; import Panel from 'react-bootstrap/lib/Panel'; import AppConstants from '../../constants/application_constants'; -import { mergeOptions } from '../../utils/general_utils'; - const { bool, element, string, oneOfType, func, object, arrayOf } = React.PropTypes; @@ -261,7 +258,7 @@ const Property = React.createClass({ // Input's props should only be cloned and propagated down the tree, // if the component is actually being shown (!== 'expanded === false') if((this.state.expanded && this.props.checkboxLabel) || !this.props.checkboxLabel) { - return ReactAddons.Children.map(this.props.children, (child) => { + return React.Children.map(this.props.children, (child) => { // Since refs will be overriden by this functions return statement, // we still want to be able to define refs for nested `Form` or `Property` // children, which is why we're upfront simply invoking the callback-ref- diff --git a/js/components/ascribe_slides_container/slides_container.js b/js/components/ascribe_slides_container/slides_container.js index 109bbae7..ccaef9cb 100644 --- a/js/components/ascribe_slides_container/slides_container.js +++ b/js/components/ascribe_slides_container/slides_container.js @@ -1,6 +1,6 @@ 'use strict'; -import React from 'react/addons'; +import React from 'react'; import { History, Lifecycle } from 'react-router'; import SlidesContainerBreadcrumbs from './slides_container_breadcrumbs'; @@ -120,7 +120,7 @@ const SlidesContainer = React.createClass({ } }, - // Since we need to give the slides a width, we need to call ReactAddons.addons.cloneWithProps + // Since we need to give the slides a width, we need to call React.cloneElement // Also, a key is nice to have! renderChildren() { const startFrom = parseInt(this.props.location.query.start_from, 10) || -1; @@ -129,7 +129,7 @@ const SlidesContainer = React.createClass({ // since the default parameter of startFrom is -1, we do not need to check // if its actually present in the url bar, as it will just not match if(child && i >= startFrom) { - return React.addons.cloneWithProps(child, { + return React.cloneElement(child, { className: 'ascribe-slide', style: { width: this.state.containerWidth diff --git a/js/components/ascribe_table/table.js b/js/components/ascribe_table/table.js index fa040a0b..207b183b 100644 --- a/js/components/ascribe_table/table.js +++ b/js/components/ascribe_table/table.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import ReactAddons from 'react/addons'; import TableHeader from './table_header'; import { ColumnModel } from './models/table_models'; @@ -20,8 +19,8 @@ let Table = React.createClass({ }, renderChildren() { - return ReactAddons.Children.map(this.props.children, (child, i) => { - return ReactAddons.addons.cloneWithProps(child, { + return React.Children.map(this.props.children, (child, i) => { + return React.cloneElement(child, { columnList: this.props.columnList, columnContent: this.props.itemList[i], key: i diff --git a/js/components/ascribe_uploader/react_s3_fine_uploader.js b/js/components/ascribe_uploader/react_s3_fine_uploader.js index 1a3baf38..ed7cfe09 100644 --- a/js/components/ascribe_uploader/react_s3_fine_uploader.js +++ b/js/components/ascribe_uploader/react_s3_fine_uploader.js @@ -1,6 +1,7 @@ 'use strict'; -import React from 'react/addons'; +import React from 'react'; +import update from 'react-addons-update'; // FIXME: remove once using react-components import fineUploader from 'exports?qq!./vendor/s3.fine-uploader'; import Q from 'q'; @@ -536,7 +537,7 @@ const ReactS3FineUploader = React.createClass({ changeSet.status = { $set: status }; - let filesToUpload = React.addons.update(this.state.filesToUpload, { [fileId]: changeSet }); + let filesToUpload = update(this.state.filesToUpload, { [fileId]: changeSet }); this.setState({ filesToUpload }, resolve); }); @@ -547,7 +548,7 @@ const ReactS3FineUploader = React.createClass({ if(fileId < filesToUpload.length) { const changeSet = { $set: url }; - const newFilesToUpload = React.addons.update(filesToUpload, { + const newFilesToUpload = update(filesToUpload, { [fileId]: { thumbnailUrl: changeSet } }); @@ -574,7 +575,7 @@ const ReactS3FineUploader = React.createClass({ completed: false }; - let startedChunks = React.addons.update(this.state.startedChunks, { $set: chunks }); + let startedChunks = update(this.state.startedChunks, { $set: chunks }); this.setState({ startedChunks }); }, @@ -588,7 +589,7 @@ const ReactS3FineUploader = React.createClass({ chunks[chunkKey].responseJson = responseJson; chunks[chunkKey].xhr = xhr; - let startedChunks = React.addons.update(this.state.startedChunks, { $set: chunks }); + let startedChunks = update(this.state.startedChunks, { $set: chunks }); this.setState({ startedChunks }); } @@ -619,7 +620,7 @@ const ReactS3FineUploader = React.createClass({ files[id].status = FileStatus.UPLOAD_SUCCESSFUL; files[id].key = this.state.uploader.getKey(id); - let filesToUpload = React.addons.update(this.state.filesToUpload, { $set: files }); + let filesToUpload = update(this.state.filesToUpload, { $set: files }); this.setState({ filesToUpload }); // Only after the blob has been created server-side, we can make the form submittable. @@ -667,7 +668,7 @@ const ReactS3FineUploader = React.createClass({ if (!this.state.errorState.errorClass) { notificationMessage = errorNotificationMessage; - const errorState = React.addons.update(this.state.errorState, { + const errorState = update(this.state.errorState, { errorClass: { $set: this.getUploadErrorClass({ reason: errorReason, @@ -720,7 +721,7 @@ const ReactS3FineUploader = React.createClass({ }, onProgress(id, name, uploadedBytes, totalBytes) { - let filesToUpload = React.addons.update(this.state.filesToUpload, { + let filesToUpload = update(this.state.filesToUpload, { [id]: { progress: { $set: (uploadedBytes / totalBytes) * 100} } @@ -747,7 +748,7 @@ const ReactS3FineUploader = React.createClass({ return file; }); - let filesToUpload = React.addons.update(this.state.filesToUpload, {$set: updatedFilesToUpload}); + let filesToUpload = update(this.state.filesToUpload, {$set: updatedFilesToUpload}); this.setState({filesToUpload }); } else { @@ -846,7 +847,7 @@ const ReactS3FineUploader = React.createClass({ fileIds.forEach((fileId) => { this.state.uploader.retry(fileId); - filesToUpload = React.addons.update(filesToUpload, { [fileId]: { status: { $set: FileStatus.UPLOADING } } }); + filesToUpload = update(filesToUpload, { [fileId]: { status: { $set: FileStatus.UPLOADING } } }); }); this.setState({ @@ -1041,7 +1042,7 @@ const ReactS3FineUploader = React.createClass({ } // set the new file array - let filesToUpload = React.addons.update(this.state.filesToUpload, { $set: oldAndNewFiles }); + let filesToUpload = update(this.state.filesToUpload, { $set: oldAndNewFiles }); this.setState({ filesToUpload }, () => { // when files have been dropped or selected by a user, we want to propagate that diff --git a/js/stores/edition_list_store.js b/js/stores/edition_list_store.js index 683e40ca..939eb063 100644 --- a/js/stores/edition_list_store.js +++ b/js/stores/edition_list_store.js @@ -1,6 +1,6 @@ 'use strict'; -import React from 'react'; +import update from 'react-addons-update'; import { alt } from '../alt'; import EditionsListActions from '../actions/edition_list_actions'; @@ -30,7 +30,7 @@ class EditionListStore { // if edition already exists, just merge if (pieceEditionList[storeEditionIndex]) { - pieceEditionList[storeEditionIndex] = React.addons.update(pieceEditionList[storeEditionIndex], { $merge: updatedEdition }); + pieceEditionList[storeEditionIndex] = update(pieceEditionList[storeEditionIndex], { $merge: updatedEdition }); } else { // if does not exist, assign pieceEditionList[storeEditionIndex] = updatedEdition; diff --git a/js/stores/piece_list_store.js b/js/stores/piece_list_store.js index 22d35c51..a5cd6b36 100644 --- a/js/stores/piece_list_store.js +++ b/js/stores/piece_list_store.js @@ -1,6 +1,6 @@ 'use strict'; -import React from 'react'; +import update from 'react-addons-update'; import { alt } from '../alt'; import PieceListActions from '../actions/piece_list_actions'; @@ -62,7 +62,7 @@ class PieceListStore { pieceList.forEach((piece, i) => { const oldPiece = this.pieceList[i]; if (oldPiece) { - piece = React.addons.update(piece, { + piece = update(piece, { show: { $set: oldPiece.show } }); } diff --git a/package.json b/package.json index 7c3ffe8a..8cbb69e2 100644 --- a/package.json +++ b/package.json @@ -95,6 +95,7 @@ "query-string": "^3.0.0", "raven-js": "^1.1.19", "react": "^15.1.0", + "react-addons-update": "^15.1.0", "react-bootstrap": "^0.29.4", "react-datepicker": "^0.27.0", "react-dom": "^15.1.0",