This file contains 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
class Operation { | |
constructor(a, b) { | |
this.a = a | |
this.b = b | |
} | |
getSum() { | |
return this.a + this.b | |
} | |
} |
This file contains 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
let user = null; | |
let age = 12; | |
let isTeenage = user?.[value++]; | |
console.log('isTeenage :: ', isTeenage); | |
// Output | |
isTeenage :: undefined |
This file contains 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 const nameStateAtom = atom({ | |
key: "nameStateAtom", // an unique id | |
default: "", // default value | |
}); |
This file contains 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 Input = () => { | |
const [name, setName] = useRecoilState(nameStateAtom); | |
const onChange = (event) => { | |
setName(event.target.value); | |
}; | |
return ( | |
<div className="input"> | |
<input placeholder="Enter name" type="text" value={name} onChange={onChange} /><br /> |
This file contains 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 const nameStateSelector = selector({ | |
key: "nameStateSelector", // unique ID | |
get: ({ get }) => { | |
const text = get(nameStateAtom); | |
return text; | |
}, | |
}); |
This file contains 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 {atom, selector, useRecoilValue} from 'recoil'; | |
const nameStateAtom = atom({ | |
key: 'nameStateAtom', | |
default: '' | |
}); | |
const nameStateSelector = selector({ | |
key: 'nameStateSelector', | |
get: ({get}) => get(nameStateAtom) | |
}); |
This file contains 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
{ | |
"name": "app-name", | |
"version": "0.0.1", | |
"dependencies": { }, | |
"devDependencies": { } | |
"scripts": { | |
"start": "react-scripts start", | |
"build": "react-scripts build", | |
"test": "react-scripts test", | |
"eject": "react-scripts eject", |
This file contains 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 { useName } from '../logics/useName'; | |
const Create = () => { | |
const { name, setName } = useName(); | |
const onChange = e => { | |
setName(e.target.value); | |
}; |
This file contains 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, { useState } from 'react'; | |
const useName = () => { | |
const [name, setValue] = useState(''); | |
const setName = name => { | |
setValue(name); | |
}; | |
return { name, setName }; |
This file contains 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 const theme = { | |
breakpoints: [32, 48, 64], | |
space: [0, 4, 8, 16, 24, 32, 48, 64, 128, 256, 512], | |
fontSizes: [12, 14, 16, 18, 20, 24, 36, 48, 80, 96], | |
fontWeights: [100, 200, 300, 400, 500, 600, 700, 800, 900], | |
lineHeights: { | |
normal: 1, | |
title: 1.25, | |
paragraph: 1.5 | |
}, |