11/**
2- * Copyright IBM Corp. 2016, 2025
2+ * Copyright IBM Corp. 2016, 2026
33 *
44 * This source code is licensed under the Apache-2.0 license found in the
55 * LICENSE file in the root directory of this source tree.
66 */
77
88import cx from 'classnames' ;
99import PropTypes from 'prop-types' ;
10- import React , { useRef , useState , type HTMLAttributes } from 'react' ;
10+ import React , { useEffect , useRef , useState , type HTMLAttributes } from 'react' ;
1111import { matches , keys } from '../../internal/keyboard' ;
1212import { useId } from '../../internal/useId' ;
1313import { usePrefix } from '../../internal/usePrefix' ;
@@ -121,7 +121,6 @@ function FileUploaderButton({
121121} : FileUploaderButtonProps ) {
122122 const prefix = usePrefix ( ) ;
123123 const [ labelText , setLabelText ] = useState ( ownerLabelText ) ;
124- const [ prevOwnerLabelText , setPrevOwnerLabelText ] = useState ( ownerLabelText ) ;
125124 const generatedId = useId ( ) ;
126125 const { current : inputId } = useRef ( id || generatedId ) ;
127126 const inputNode = useRef < HTMLInputElement > ( null ) ;
@@ -134,11 +133,9 @@ function FileUploaderButton({
134133 [ `${ prefix } --layout--size-${ size } ` ] : size ,
135134 } ) ;
136135
137- // Adjust label text state based on changes to the labelText prop
138- if ( ownerLabelText !== prevOwnerLabelText ) {
136+ useEffect ( ( ) => {
139137 setLabelText ( ownerLabelText ) ;
140- setPrevOwnerLabelText ( ownerLabelText ) ;
141- }
138+ } , [ ownerLabelText ] ) ;
142139
143140 function onClick ( event ) {
144141 event . target . value = null ;
0 commit comments