diff --git a/babel.config.js b/babel.config.js index 0237633bf..6e2c3800b 100644 --- a/babel.config.js +++ b/babel.config.js @@ -8,6 +8,7 @@ module.exports = function (api) { [ '@babel/preset-react', { + runtime: 'automatic', development: !isProductionEnv, useBuiltIns: true, }, diff --git a/client/app/bundles/comments/components/CommentBox/CommentForm/CommentForm.jsx b/client/app/bundles/comments/components/CommentBox/CommentForm/CommentForm.jsx index de946ea0a..ea81d06e9 100644 --- a/client/app/bundles/comments/components/CommentBox/CommentForm/CommentForm.jsx +++ b/client/app/bundles/comments/components/CommentBox/CommentForm/CommentForm.jsx @@ -1,7 +1,6 @@ /* eslint-disable react/no-find-dom-node, react/no-string-refs */ import React from 'react'; import PropTypes from 'prop-types'; -import ReactDOM from 'react-dom'; import { CSSTransition, TransitionGroup } from 'react-transition-group'; import _ from 'lodash'; import { injectIntl } from 'react-intl'; @@ -27,6 +26,13 @@ class CommentForm extends BaseComponent { comment: emptyComment, }; + this.horizontalAuthorRef = React.createRef(); + this.horizontalTextRef = React.createRef(); + this.stackedAuthorRef = React.createRef(); + this.stackedTextRef = React.createRef(); + this.inlineAuthorRef = React.createRef(); + this.inlineTextRef = React.createRef(); + _.bindAll(this, ['handleSelect', 'handleChange', 'handleSubmit', 'resetAndFocus']); } @@ -40,22 +46,20 @@ class CommentForm extends BaseComponent { switch (this.state.formMode) { case 0: comment = { - author: ReactDOM.findDOMNode(this.refs.horizontalAuthorNode).value, - text: ReactDOM.findDOMNode(this.refs.horizontalTextNode).value, + author: this.horizontalAuthorRef.current.value, + text: this.horizontalTextRef.current.value, }; break; case 1: comment = { - author: ReactDOM.findDOMNode(this.refs.stackedAuthorNode).value, - text: ReactDOM.findDOMNode(this.refs.stackedTextNode).value, + author: this.stackedAuthorRef.current.value, + text: this.stackedTextRef.current.value, }; break; case 2: comment = { - // This is different because the input is a native HTML element - // rather than a React element. - author: ReactDOM.findDOMNode(this.refs.inlineAuthorNode).value, - text: ReactDOM.findDOMNode(this.refs.inlineTextNode).value, + author: this.inlineAuthorRef.current.value, + text: this.inlineTextRef.current.value, }; break; default: @@ -81,13 +85,13 @@ class CommentForm extends BaseComponent { let ref; switch (this.state.formMode) { case 0: - ref = ReactDOM.findDOMNode(this.refs.horizontalTextNode); + ref = this.horizontalTextRef.current; break; case 1: - ref = ReactDOM.findDOMNode(this.refs.stackedTextNode); + ref = this.stackedTextRef.current; break; case 2: - ref = ReactDOM.findDOMNode(this.refs.inlineTextNode); + ref = this.inlineTextRef.current; break; default: throw new Error(`Unexpected state.formMode ${this.state.formMode}`); @@ -103,15 +107,15 @@ class CommentForm extends BaseComponent {
-