File tree Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -11,15 +11,10 @@ import styles from 'components/TextInput/TextInput.scss';
1111import { withForwardedRef } from 'lib/withForwardedRef' ;
1212
1313class TextInput extends React . Component {
14- componentWillReceiveProps ( props ) {
14+ componentDidUpdate ( props ) {
1515 if ( props . multiline !== this . props . multiline ) {
1616 const node = props . forwardedRef . current ;
17- // wait a little while for component to re-render
18- setTimeout ( function ( ) {
19- node . focus ( ) ;
20- node . value = '' ;
21- node . value = props . value ;
22- } . bind ( this ) , 1 ) ;
17+ node . focus ( ) ;
2318 }
2419 }
2520
Original file line number Diff line number Diff line change @@ -2,7 +2,9 @@ import React from 'react';
22
33export function withForwardedRef ( Component ) {
44 function render ( props , ref ) {
5- return < Component { ...props } forwardedRef = { ref } /> ;
5+ const innerRef = React . useRef ( ) ;
6+ React . useImperativeHandle ( ref , ( ) => innerRef . current , [ props . multiline ] ) ;
7+ return < Component { ...props } forwardedRef = { innerRef } /> ;
68 }
79
810 const name = Component . displayName || Component . name ;
You can’t perform that action at this time.
0 commit comments