LoginSignup
28
13

More than 1 year has passed since last update.

ワタシ、 jQuery ツカッテキタ

ワタシ、 Vue 2 ツカッテキタ

jsx? tsx?

アタラシイ拡張子、ナニソレ、コワイ

vue 拡張子、シラナイ、でも vue センヨウ拡張子ナンデショ。

index.vue
<template>
  <h1>Hello {{ userName }}!</h1>
</template>

<script>
export default {
  data: () => {
    return {
      userName: 'il-m-yamagishi',
    };
  },
};
</script>

シングルファイルコンポーネント、カンタン、ワカル

React ワカラナイ、コワイ

デモツカッテミル。エンジニア、チョウセン、スル

index.jsx
import React from 'react';

const Index = ({ userName }) => {
  return <h1>Hello {userName}!</h1>;
};

export default Index;

ナニコレ、コワイ。 JavaScript ノナカニ HTML ノッテル!!

...

アレ、デモ、コッチノホウガ カンタンカモ?

関心ノ分離、デキテル。

タダノ関数ダカラ、状態ガナクテワカリヤスイ。

ソレニ コレ、糖衣構文ラシイ。

これは JSX と呼ばれる JavaScript の構文の拡張です。UI がどのような見た目かを記述するために、React とともに JSX を使用することを私たちはお勧めしています。JSX はテンプレート言語を連想させるでしょうが、JavaScript の機能を全て備えたものです。
https://ja.reactjs.org/docs/introducing-jsx.html

index.js
import React from 'react';

const Index = ({ userName }) => {
  return React.createElement(
    'h1',
    {},
    'Hello ' + userName + '!'
  );
};

export default Index;

コレヲ ワカリヤスク カキクダスノガ jsx ナンダネ。ワカッテキタ。

index.tsx
import React from 'react';

type IndexProps = {
  userName: string,
};

const Index: React.FC<IndexProps> = ({ userName }) => {
  return <h1>Hello {userName}!</h1>;
};

export default Index;

TypeScript モキレイニ型ガウメコメル。キモチイイ。

jsx, tsx ワカッタ。 vue ヨリキモチイイ カモ。

ミンナモ クワズキライ セズ tsx ツカッテミテ。

28
13
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
28
13