Skip to content

Instantly share code, notes, and snippets.

View srdjanRakic's full-sized avatar

Srdjan Rakic srdjanRakic

View GitHub Profile
@srdjanRakic
srdjanRakic / readme.md
Last active July 9, 2020 10:27
Paywall v3
// imports whole library
import { Label, Input, TextArea } from '@inplayer-org/inplayer-ui';
// imports whole library too
// because the *src/index.js* from the library imports/exports Label component
import { Label } from '@inplayer-org/inplayer-ui';
// imports Label as standalone component
// without import whole library
import Label from '@inplayer-org/inplayer-ui/lib/Label';;
@srdjanRakic
srdjanRakic / react-lazy.js
Last active May 21, 2020 11:59
Bundle your components into chunks using React.lazy. Let's say you have a folder with several components, A, B, and C, D which should be bundled together.
// Assuming A through D are all regular React component declarations...
// components/A.js
export default function A() {
return <div>Hello, World!</div>
}
// Use React.lazy to create a dynamically loaded version of the component
// components/index.js
export const A = React.lazy(() => import(/* webpackChunkName: "top" */ "./A"));
export const B = React.lazy(() => import(/* webpackChunkName: "top" */ "./B"));
@srdjanRakic
srdjanRakic / BUG_REPORT_TEMPLATE.md
Last active January 30, 2021 10:51
Bug report template
Type Title About Project or url Env
e.g. Bug report
e.g. Login Issue
e.g. Unable to login
e.g Merchant Panel
e.g. Staging

EXPECTED BEHAVIOR

What's the behavior you're expecting to see?

ACTUAL BEHAVIOR

What's actually happening instead?

STEPS TO REPRODUCE

@srdjanRakic
srdjanRakic / delete-node-modules.md
Last active June 29, 2024 10:28
How to Delete ALL node_modules folders on your machine

List all node_modules found in a Directory:

First, let's take a look at ALL the node_modules we have in a directory, before we actually start deleting them!

Mac / Linux:

cd documents
find . -name "node_modules" -type d -prune -print | xargs du -chs
@srdjanRakic
srdjanRakic / interview-task.md
Last active November 29, 2019 12:51
Build a Quiz App with HTML, CSS, and JavaScript

Build a Quiz App with HTML, CSS, and JavaScript

Quiz App

1. Create and Style the Home Page

Create the home page along with a good chunk of the necessary CSS.

I encourage you all to take a look at Emmet snippets for generating HTML and CSS.

@srdjanRakic
srdjanRakic / hooks.md
Last active September 6, 2019 07:43
6 Basic Hooks explained in 1 sentence each

useState:

Persist value between renders, trigger re-render.

useRef:

Persist value between renders, no re-render.

useEffect:

Side effects that run after render.

useReducer:

useState in reducer pattern.

useMemo:

Memoize value between renders.

@srdjanRakic
srdjanRakic / hooks.md
Created September 6, 2019 07:39
6 Basic Hooks explained in 1 sentence each

useState: Persist value between renders, trigger re-render useRef: Persist value between renders, no re-render useEffect: Side effects that run after render useReducer: useState in reducer pattern useMemo: Memoize value between renders useCallback: Persist ref equality between renders

@srdjanRakic
srdjanRakic / optional-chaining.js
Created August 29, 2019 07:21
This feature enables readable and concise expression of property accesses with built-in nullish checking.
const object = { id: 123, names: { first: 'Srdjan', last: 'Rakic' }};
// With lodash's `_.get`:
const firstName = _.get(object, 'names.first'); // -> 'Srdjan'
const middleName = _.get(object, 'names.middle' : '(no middle name)'); // -> '(no middle name)'
// with optional chaining and nullish coalescing:
const firstName = object?.names?.first ?? '(no first name)'; // -> 'Srdjan'
const middleName = object?.names?.middle ?? '(no middle name)'; // -> '(no middle name)'