1

When 'gulp serve' my SharePoint extension solution, I am receiving this error

Type { label: string; required: true; name: string; defaultValue: string; onChanged: (text: string) => void; } is not assignable to type 'IntrinsicAttributes & ITextFieldProps & { children?: ReactNode; }'. Property 'onChanged' does not exist on type 'IntrinsicAttributes & ITextFieldProps & { children?: ReactNode; }.ts(2322)

I am using:

@microsoft/generator-sharepoint@1.10.0 gulp@4.0.2 npm@6.14.4 yo@3.1.1

SendEMailDialogContent.tsx file code below:

import * as React from 'react';
import {
    TextField,
    PrimaryButton,
    Button,
    DialogFooter,
    DialogContent,
    Spinner,
    SpinnerSize
} from 'office-ui-fabric-react';
import { ISendEMailDialogContentProps } from './ISendEMailDialogContentProps';
import { EMailProperties, EMailAttachment } from '../models';
import { ISendEMailDialogContentState } from './ISendEMailDialogContentState';

export class SendEMailDialogContent extends React.Component<ISendEMailDialogContentProps, ISendEMailDialogContentState> {
    private _eMailProperties: EMailProperties;

    constructor(props) {
        super(props);
        this.state = {
            isLoading: false
        };
        this._eMailProperties = this.props.eMailProperties;        
        this._onChangedTo = this._onChangedTo.bind(this);
        this._onChangedSubject = this._onChangedSubject.bind(this);
        this._onChangedBody = this._onChangedBody.bind(this);
        this._submit = this._submit.bind(this);
    }

    public render(): JSX.Element {
        var getDialogContent = () => {
            if (this.state.isLoading) {
                return (
                    <Spinner size={SpinnerSize.large} label="loading..." ariaLive="assertive" />
                );
            }
            else {
                return (
                    <div>
                        <TextField label='To' required={true} name="To" defaultValue={this._eMailProperties.To} onChanged={this._onChangedTo} />
                        <TextField label='Subject' required={true} defaultValue={this._eMailProperties.Subject} onChanged={this._onChangedSubject} />
                        <TextField label='Body' required={true} multiline defaultValue={this._eMailProperties.Body} onChanged={this._onChangedBody} />

                        <DialogFooter>
                            <Button text='Cancel' title='Cancel' onClick={this.props.close} />
                            <PrimaryButton text='OK' title='OK' onClick={this._submit} />
                        </DialogFooter>
                    </div>);
            }
        };
        // UI
        return <DialogContent
            title='Send E-Mail Details'
            subText=''
            onDismiss={this.props.close}
            showCloseButton={true}
        >
            {getDialogContent()}
        </DialogContent>;
    }

    private _onChangedSubject(text: string) {
        this._eMailProperties.Subject = text;
    }    

    private _onChangedTo(text: string) {
        this._eMailProperties.To = text;
    }    

    private _onChangedBody(text: string) {
        this._eMailProperties.Body = text;
    }

The error is related to the TextField - onChanged={this._onChangedxxxxx}

ibrahim
  • 195
  • 1
  • 2
  • 14

1 Answers1

1

Depending on the version of office-ui-fabric-react being used, it's likely that this callback is now called onChange instead of onChanged.

In addition to being renamed, onChange expects the first argument to be a react event, so you'll need to change your onChanged* methods to expect one more argument (and they're free to ignore it).

Relevant documentation: https://developer.microsoft.com/en-us/fluentui#/controls/web/textfield#implementation

JD Huntington
  • 348
  • 1
  • 5