Skip to content

Instantly share code, notes, and snippets.

body {
font: 14px "Century Gothic", Futura, sans-serif;
margin: 20px;
}
ol, ul {
padding-left: 30px;
}
.board-row:after {
import React, { useState } from "react";
import ReactDOM from "react-dom";
import './css/react-tutorial.css';
interface BoardProps {
squares: ISquare[];
onClick: (i: number) => void;
}
interface SquareProps {
value: ISquare;
var gulp = require('gulp');
var pug = require('gulp-pug');
// gulp.task('タスク名', 実行される処理)でタスク作成
gulp.task('default', () => {
gulp.src(
['./pug/**/*.pug', '!./pug/**/_*.pug']
)
.pipe(pug({
pretty: true
doctype
html(lang="ja")
head
meta(charset="utf-8")
meta(name="viewport" content="width=device-width,initial-scale=1.0")
title Tweet Share
link(rel="stylesheet" href="style.css")
body
header
h1 Tweet Share
import React, { useReducer } from "react";
import ReactDOM from "react-dom";
const initData = {
num: 0,
message: "クリックしてください"
}
const reducer = ({num} , action) => {
// eslint-disable-next-line
@chobi1125
chobi1125 / react-useReducer-counter
Created June 4, 2020 04:05
Reduxを使わない
import React, { useContext, useReducer, createContext } from "react";
import ReactDOM from "react-dom";
const DispatchContext = createContext(() => {});
const reducer = (num , action) => {
//eslint-disable-next-line
switch (action) {
case 'increment':
return num + 1;
import React, { useContext, useReducer, createContext } from "react";
import ReactDOM from "react-dom";
const DispatchContext = createContext(() => {});
const reducer = ({ year, month }, action) => {
//eslint-disable-next-line
switch (action) {
case 'increment':
return month === 11
@chobi1125
chobi1125 / react-function-allow.js
Created June 3, 2020 04:57
なるべく省略記法を利用して書いてみました。
import React from 'react';
import { connect } from 'react-redux';
import './App.css';
const mappingState = state => state ;
// Appコンポーネント
const App = () => {
const style = {
color: "blue"
}
import React from 'react';
import { connect } from 'react-redux';
import './App.css';
// ステートのマッピング
function mappingState(state) {
return state;
}
// Appコンポーネント
function App() {
const style = {
@chobi1125
chobi1125 / index.ts
Created May 29, 2020 11:00
TypeScriptの学習
let t:string | null = "Hello TypeScript!!";
t = null;
console.log(t);
// 配列の型推論
let n:number[] = [1,2,3,4];
console.log(n[0]);
// オブジェクトの型推論。interfaceの代わりにtypeでもOK
interface User {
id: number
name: string