Skip to content

Instantly share code, notes, and snippets.

View raflyfahrezi's full-sized avatar
🔥

Farhan Rafly Fahrezi S raflyfahrezi

🔥
View GitHub Profile
@raflyfahrezi
raflyfahrezi / _document.js
Last active December 28, 2020 07:33
_document.js configuration when using Styled Components in Next.js
import Document from 'next/document'
import { ServerStyleSheet } from 'styled-components'
export default class MyDocument extends Document {
static async getInitialProps(ctx) {
const sheet = new ServerStyleSheet()
const originalRenderPage = ctx.renderPage
try {
ctx.renderPage = () =>
{
"presets": ["next/babel"],
"plugins": [["styled-components", {
"ssr" : true
}]]
}
@raflyfahrezi
raflyfahrezi / date.js
Created December 18, 2020 02:48
Javascript Date Full Month
const dateFormat = paramsDate => {
const month = new Array()
let temp = paramsDate
month[0] = 'January'
month[1] = 'February'
month[2] = 'March'
month[3] = 'April'
month[4] = 'May'
month[5] = 'June'
@raflyfahrezi
raflyfahrezi / globals.css
Last active December 28, 2020 07:32
Custom Scroll CSS
::-webkit-scrollbar {
width: 5px;
height: 5px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
@raflyfahrezi
raflyfahrezi / fonts.jsx
Last active February 3, 2021 01:46
Declare fonts for theming
const Fonts = {
fontFamily: 'your fonts name',
fontSize: {
12: '12px',
14: '14px',
16: '16px',
20: '20px',
24: '24px',
32: '32px',
48: '48px',
@raflyfahrezi
raflyfahrezi / index.js
Created January 9, 2021 14:02
Script TikTok Video Downloader - Open some videos, open devtools, paste this code at console. Your are done.
const videos = document.getElementsByTagName("VIDEO")
window.open(videos[0].src)
@raflyfahrezi
raflyfahrezi / index.jsx
Last active May 25, 2021 22:42
fetching data in useEffect
import React, { useEffect, useState } from 'react'
import axios from 'axios'
const index = () => {
const [data, setData] = useState([])
useEffect(async () => {
const response = await axios.get('...some API path...')
setData(response.data)
@raflyfahrezi
raflyfahrezi / index.jsx
Last active May 25, 2021 22:42
fetching data using getStaticProps
import React from 'react'
import axios from 'axios'
const index = ({ data }) => {
return (
<div>
{data.map((item, index) => {
return (
<div key={index}>{item.name}</div>
)
@raflyfahrezi
raflyfahrezi / index.jsx
Created May 25, 2021 22:41
fetching data using getServerSideProps
import React from 'react'
import axios from 'axios'
const index = ({ data }) => {
return (
<div>
{data.map((item, index) => {
return (
<div key={index}>{item.name}</div>
)
@raflyfahrezi
raflyfahrezi / index.jsx
Created May 25, 2021 23:12
fetcing data using swr
import React from 'react'
import useSWR from 'swr'
import { fetcher } from '../utils'
const index = () => {
const { data } = useSWR('... some API Fetch ...', fetcher)
return (
<div>