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 MyComponent extends React.Components { | |
constructor () { | |
this.state = { | |
a: 0, | |
b: 'foo' | |
} | |
} | |
handerClick = () => { | |
this.setState({ |
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, useEffect } from 'react' | |
import styled from 'styled-components' | |
import { Box } from 'atomic-layout' | |
const StyledInput = styled.input` | |
background-color: #282828; | |
color: #fff; | |
width: 100%; | |
padding: 16px; | |
border: none; |
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, useRef } from 'react' | |
import debounce from 'lodash.debounce' | |
const Search = () => { | |
// state text which was written in the input | |
const [value, setValue] = useState('') | |
// using "useRef" so that React doesn't create | |
// debounced function on each render (after state update). | |
const doSearch = useRef( |
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
```css | |
.videoWrapper { | |
position: relative; | |
padding-bottom: 56.25%; /* 16:9 */ | |
padding-top: 25px; | |
height: 0; | |
} | |
.videoWrapper iframe { | |
position: absolute; | |
top: 0; |
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 Toggle = () => { | |
const [isToggle, setIsToggle] = React.useState(true) | |
const handleClick = () => { | |
setIsToggle(!isToggle) | |
} | |
return ( | |
<button onClick={handleClick}>{isToggle ? 'On' : 'Off'}</button> | |
) |
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
.tooltip { | |
position: absolute; | |
top: 100%; | |
left: 0; | |
width: 100%; | |
max-width: 350px; | |
padding: 0.5rem 1rem; | |
background-color: #fff; | |
border: 1px solid #000; | |
border-radius: 4px; |
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 interface ProductData { | |
id: string | |
title: string | |
description: string | |
rating: number | |
price: number | |
images: string[] | |
relatedProducts: string[] | |
shopAttributes: ProductAttributes[] | |
reviews: ProductReview[] |
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
useEffect(() => { | |
console.log("[Cockpit.js] useEffect"); | |
const timer = setTimeout(() => { | |
alert("foo time out"); | |
}, 1000); | |
return () => { | |
clearTimeout(timer); | |
}; | |
}, []); |
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
state = { | |
persons: [ | |
{ id: 'asfa1', name: 'Max', age: 28 }, | |
{ id: 'vasdf1', name: 'Manu', age: 29 }, | |
{ id: 'asdf11', name: 'Stephanie', age: 26 } | |
], | |
otherState: 'some other value', | |
showPersons: false, | |
showCockpit: true, | |
changeCounter: 0 |
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, { useEffect, useRef } from "react"; | |
interface CockpitProps { | |
onClick: any; | |
persons: any[]; | |
personsLength: any; | |
} | |
export const Cockpit: React.FC<CockpitProps> = React.memo(props => { | |
const toggleBtnRef = useRef<HTMLButtonElement>(null); |
OlderNewer