Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

state in react typescript

interface IProps {
}

interface IState {
  playOrPause?: string;
}

class Player extends React.Component<IProps, IState> {
  // ------------------------------------------^
  constructor(props: IProps) {
    super(props);

    this.state = {
      playOrPause: 'Play'
    };
  }

  render() {
    return(
      <div>
        <button
          ref={playPause => this.playPause = playPause}
          title={this.state.playOrPause} // in this line I get an error
        >
          Play
        </button>
      </div>
    );
  }
}
Comment

state typescript

import { Student } from "../../@models/student";

export {};
declare global {
  interface studentState {
    student: Student[];
    loading?: boolean;
    searchData: Student[];
  }
}
Comment

typescript types for state

interface IProps {
}

interface IState {
  playOrPause?: string;
}

class Player extends React.Component<IProps, IState> {
  // ------------------------------------------^
  constructor(props: IProps) {
    super(props);

    this.state = {
      playOrPause: 'Play'
    };
  }

  render() {
    return(
      <div>
        <button
          ref={playPause => this.playPause = playPause}
          title={this.state.playOrPause} // in this line I get an error
        >
          Play
        </button>
      </div>
    );
  }
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: INTENT 
Typescript :: Update multiple documents with different field value by id set. Mongoose 
Typescript :: node scripts delay 
Typescript :: check if variable exists python 
Typescript :: behaviour 
Typescript :: what are the three ways for a developer to execute tests in an org 
Typescript :: .setRowHeights google script 
Typescript :: whats a 3rd wheel 
Typescript :: unity destroy all objects with tag 
Typescript :: get coin prices node-binance 
Cpp :: find largest number in vector c++ 
Cpp :: no indentation latex 
Cpp :: excel vba delete worksheet if exists 
Cpp :: flutter convert datetime in day of month 
Cpp :: fahrenheit to kelvin formula 
Cpp :: how to check string contains char in c++ 
Cpp :: simple C++ game code 
Cpp :: how to find index of a vector in c++ 
Cpp :: eosio check account exist 
Cpp :: infinity c++ 
Cpp :: unreal get eobjecttypequery cpp´ 
Cpp :: retourner pointeur de type qstringlist qt 
Cpp :: char type casting in c++ 
Cpp :: google test assert eq float 
Cpp :: call of overloaded ‘swap(int&, int&)’ is ambiguous 
Cpp :: dlopen failed: library "libomp.so" not found 
Cpp :: finding no of unique characters in a string c++ 
Cpp :: c++ print current time 
Cpp :: convert string to char c++ 
Cpp :: C++ mutex lock/unlock 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =