import * as React from 'react'; import { TextField, ITextFieldStyles } from 'office-ui-fabric-react/lib/TextField'; import { Stack } from 'office-ui-fabric-react/lib/Stack'; import { useConstCallback } from '@uifabric/react-hooks'; const textFieldStyles: Partial = { fieldGroup: { width: 300 } }; const narrowTextFieldStyles: Partial = { fieldGroup: { width: 100 } }; const stackTokens = { childrenGap: 15 }; export const TextFieldControlledExample: React.FunctionComponent = () => { const [firstTextFieldValue, setFirstTextFieldValue] = React.useState(''); const [secondTextFieldValue, setSecondTextFieldValue] = React.useState(''); const onChangeFirstTextFieldValue = useConstCallback( (event: React.FormEvent, newValue?: string) => { setFirstTextFieldValue(newValue || ''); }, ); const onChangeSecondTextFieldValue = useConstCallback( (event: React.FormEvent, newValue?: string) => { if (!newValue || newValue.length <= 5) { setSecondTextFieldValue(newValue || ''); } }, ); return ( ); };