sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

setState has problem

Open peterremote1980 opened this issue 8 years ago • 3 comments

Hi I got this:

Error - typescript - src/webparts/annualLeaveForm/components/AnnualLeaveForm.tsx(242,22): error TS2345: Argument of type '{ leaveType: any; }' is not assignable to parameter of type '{ leaveType: any; vacationRequest: any; }'.

export default class AnnualLeaveForm extends React.Component<IAnnualLeaveFormProps, { leaveType: any, vacationRequest: any }> {

this.setState({ vacationRequest: value[item] });

If i have two variables in state, i can't set only one? i am using node v8.11.4.

thanks Peter

peterremote1980 avatar Aug 24 '18 02:08 peterremote1980

Has nothing to do with the Node version, we think you need to use the setState as official docus

Seiyasu avatar Aug 24 '18 05:08 Seiyasu

in windows, compile is ok, but in mac fail. I solved it by adding ? after variable name. Now it can be compile in both windows and mac. thanks

peterremote1980 avatar Aug 24 '18 18:08 peterremote1980

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 27 '20 00:01 msft-github-bot