This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gql from "graphql-tag" | |
import { ASTNode } from "graphql" | |
export function extractTypeFromSchema( | |
expectTypeName: string[], | |
schema?: ASTNode, | |
result: string[] = [] | |
): string[] { | |
/** | |
* Implementation... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## BK1 deployment script with SSH | |
if [ -z "$SSH_DEPLOYMENT_SERVER" ] | |
then | |
echo ERROR: please provide SSH_DEPLOYMENT_SERVER variable to deploy instance to server | |
exit 1 | |
else | |
echo Deploy BK1 API server instance to $SSH_DEPLOYMENT_SERVER | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// THIS COMPONENT CANNOT HAVE STATE | |
const MyInputComponent ({ value, onChange }) => { | |
return ( | |
<input value={value} onChange={onChange} /> | |
) | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOW ( currently on alpha 14 nov 2018 ) THIS COMPONENT CAN HAVE STATE | |
const MyInputComponent ({ }) => { | |
const [value, setValue] = React.useState("put some default value here") | |
const onChange = (e) => setValue(e.value.target) | |
return ( | |
<input value={value} onChange={onChange} /> | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type TodoItem = { | |
title: string | |
completed: boolean | |
} | |
type TodoState = { | |
// ชนิดของ filter ที่ toggle อยู่ | |
filter: "All" | "Active" | "Completed", | |
// Todo ทั้งหมด |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TodosApp = () => { | |
// Declare every state we need to store | |
const [filter, setFilter] = React.useState<TodoState["filter"]>("All"); | |
const [todos, setTodo] = React.useState<TodoState["todos"]>([]); | |
const [textInput, setTextInput] = React.useState<TodoState["textInput"](""); | |
return ( /** implement UI */ ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import "./App.css"; | |
import "todomvc-common/base.css"; | |
import "todomvc-app-css/index.css"; | |
// เขียน ทุก component รวมกันในไฟล์เดียว | |
// เพื่อความสะดวกในการเขียนบทความ | |
const TodoInput = () => <div />; | |
const TodoList = () => <div />; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TodoInput.jsx | |
const TodoInput = () => { | |
const [textInput, setTextInput] = React.useState(""); | |
function onTextChange(e) { | |
setTextInput(e.target.value); | |
} | |
return ( | |
<input className="new-todo" value={textInput} onChange={onTextChange} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TodoStoreContext = React.createContext(); | |
const TodoStoreProvider = ({ children }) => { | |
const store = { | |
todos: [ | |
{ | |
title: "Touch myself." | |
}, | |
{ | |
title: "Sleep peacefully" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default () => ( | |
<TodoStoreProvider> | |
<div className="App todoapp"> | |
<header className="header"> | |
<h1>todos</h1> | |
<TodoInput /> | |
</header> | |
<section className="main"> |