Here's my code:
export type State = {hddstate: string, cpustate: string};
export type Properties = {};
export class SearchComponent extends React.Component<Properties, State> {
private inputTimer?: number;
constructor(properties: Properties) {
super(properties);
this.state = {
hddstate: "turned off",
cpustate: "turned off"
};
}
public CpuStatus(): void {
this.setState({hddstate: "turned off"});
this.setState({cpustate: "turned on"});
}
When I call CpuStatus(), I get "Uncaught TypeError: Cannot read property 'setState' of undefined"
Why does this happen and how can I fix this?