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 :: git delete commits from remote 
Typescript :: find unique values between 2 lists R 
Typescript :: typescript interface property multiple types 
Typescript :: promise allsettled typescript 
Typescript :: replace element in array typescript 
Typescript :: how push objects into a local stotage array 
Typescript :: provider in ethers.js 
Typescript :: main.ts is missing from the typescript compilation 
Typescript :: targe id that starts with 
Typescript :: rails_env production rake assets precompile 
Typescript :: disable out of stock products shopify 
Typescript :: Create Type from String Enum 
Typescript :: git squash commits on branch 
Typescript :: typescript loop types 
Typescript :: Parameter type from function TypeScript 
Typescript :: serenity.is hide form field 
Typescript :: validation minlength angular 
Typescript :: shortid typescript 
Typescript :: get and set in typescript 
Typescript :: module.exports mongodb connection 
Typescript :: typescript one of array 
Typescript :: angular loadchildren lazy loading 
Typescript :: pytest tests in subfolder 
Typescript :: order documents in firestore 
Typescript :: int sum. 
Typescript :: SafeValue must use [property]=binding: 
Typescript :: nuxt 3 nuxtServerInit 
Typescript :: declare type function typescript 
Typescript :: testing in different environments 
Typescript :: algorithm that prints if one of the numbers is multiple of the other 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =