1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

TypeScript メモ

Last updated at Posted at 2018-09-09

普段使いをし始めて半年。
かなりわかりやすいと思っていまいます。
reactを使用しますので、Typescript Reactな開発に使います。
それ以外にも、基本はTypeScriptを使用します。

React

import * as React from 'react';
import { View } from './view';

// Propsの型定義
interface IProps {
    name: string;
}

interface IState {
    count: number;
}

export class Profile extends React.Component<IProps, IState> {
    constructor(props) {
        super(props);
        this.state = {
            count: 0,
        };
    }

    handleClick() {
        const text_element = document.getElementsByClassName("modal")[0];
        if (text_element.className === "modal on") {
            text_element.classList.remove("on");
        } else {
            text_element.classList.add("on");
        }
    }

    render() {

        return (
            <div>
                <h2>{this.props.name}</h2>
                <div className="text">
                    <p onClick={this.handleClick.bind(this)}>texttexttexttext</p>
                </div>
                <div className="textsub"></div>
                <View />
            </div>
        );
    }
}

書き方に差があまりないので、実践で使いやすいかと思います。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?