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
npm install - save-dev @babel/core @babel/cli @babel/plugin-proposal-optional-chaining |
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 personOne = { | |
firstName: "Denny", | |
lastName: "Scott", | |
contact: { | |
phoneNumber: 555–555–5555, | |
twitter: "@gitinbit" | |
} | |
} | |
function getUserForPhoneDirectory(person) { |
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
npx babel - plugins @babel/plugin-proposal-optional-chaining index.js |
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
function getUserForPhoneDirectory(person) { | |
var _person$contact; | |
const firstName = person === null || person === void 0 ? void 0 : person.firstName; | |
const lastName = person === null || person === void 0 ? void 0 : person.lastName; | |
const phoneNumber = person === null || person === void 0 ? void 0 : (_person$contact = person.contact) === null || _person$contact === void 0 ? void 0 : _person$contact.phoneNumber; | |
if (firstName && lastName && phoneNumber) { | |
return `${firstName} ${lastName} - ${phoneNumber}`; | |
} | |
} |
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
{ | |
"plugins": [ | |
"@babel/plugin-proposal-optional-chaining" | |
] | |
} |
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 styled from 'styled-components'; | |
const Card = styled.div` | |
box-sizing: border-box; | |
max-width: 410px; | |
margin: 0 auto; | |
padding: 0 2rem; | |
display: flex; | |
flex-direction: column; | |
align-items: center; |
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, { useState } from "react" | |
... | |
function App(props) { | |
const existingTokens = JSON.parse(localStorage.getItem("tokens")); | |
const [authTokens, setAuthTokens] = useState(existingTokens); | |
const setTokens = (data) => { | |
localStorage.setItem("tokens", JSON.stringify(data)); | |
setAuthTokens(data); | |
} |
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
'no-restricted-syntax': [ | |
'error', | |
{ | |
selector: "CallExpression[callee.name='require']", | |
message: 'Require is no longer allowed, please use an import statement' | |
} | |
] |
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, { useState } from 'react'; | |
function Header(props) { | |
const [title, setTitle] = useState('Title'); | |
} |
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, { useState } from “react”; | |
export default function App() { | |
const [counter, setCounter] = useState(1); | |
const onClick = () => { | |
setCounter(counter + 1); | |
console.log(counter); | |
}; |