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
/* | |
* Appying Separation of concenrns to React component. Separate logic out of Component using hooks. | |
*/ | |
const useSingleProduct = (productId) => { | |
const [product, setProduct] = useState(null); | |
const fetchProduct = async () => { | |
const res = await fetch(`https://api.example.com/products/${productId}`); | |
setProduct(res.json()); |
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
/* eslint-disable */ | |
import "./styles.css"; | |
import { useState, useRef, useEffect } from "react"; | |
const generateId = (() => { | |
let count = 0; | |
return () => { | |
return ++count; | |
}; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Вопросы по CSS</title> | |
</head> | |
<style> | |
.question { | |
position: relative; | |
} |
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
console.log('hello'); | |
const WORLD = 'world'; | |
console.log(WORLD); |
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
https://gist.github.com/sb-bilal-dev/e952d42ed0cbb766677d028230d62ff8 |
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
// On renders | |
const renderFoo = (data) => (<div>{data.code}</div>) | |
// On some shit code | |
cosnt mapState = (state) => ({ | |
userName: state.users && state.users.activeUser && state.users.activeUser.name, | |
customer: state.customer && state.customer.cars, | |
}) | |
// Inside conditional expressions |
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 '../../styles/typography.mixins'; | |
@import '../../styles/palette.variables'; | |
$border-radius: 4px; | |
$input-padding-h: 16px; | |
$icon-size-small: 16px; | |
$icon-size-medium: 24px; | |
$icon-size-large: 24px; | |
$input-margin-v: 4px; | |
$input-width: 220px; |
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, { MouseEvent, ChangeEvent, forwardRef, FocusEvent } from 'react'; | |
import classNames from 'classnames'; | |
import { IconName } from 'app/design-system/types/Icon'; | |
import { Palette } from 'app/design-system/constants/Palette'; | |
import styles from './styles.module.scss'; | |
import { InputSize } from './types'; | |
import IconButton from './IconButton'; | |
import { ICON_SIZE_BY_NAME } from './constants'; |
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
// Now let's log props.dogCount | |
const MyDogHouse = (props) => ( | |
<div>{props.dogCount}</div> | |
) | |
// It will change like this | |
const MyDogHouse = (props) => ( | |
<div>{(console.log(props.dogCount), props.dogCount)}</div> | |
) |
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's log catCount | |
if (isLogging && catCount === 10) {} | |
// You can do it like this | |
if (isLogging && (console.log(catCount), catCount === 10)) {} |
NewerOlder