Answers for "react ts state"

2

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>
    );
  }
}
Posted by: Guest on July-14-2020
0

state typescript

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

export {};
declare global {
  interface studentState {
    student: Student[];
    loading?: boolean;
    searchData: Student[];
  }
}
Posted by: Guest on March-08-2022

Code answers related to "TypeScript"

Browse Popular Code Answers by Language