Skip to content

Instantly share code, notes, and snippets.

View iammilaad's full-sized avatar
🏠
Working from home

Milad Heydari iammilaad

🏠
Working from home
View GitHub Profile
@iammilaad
iammilaad / isEmpty.js
Created May 10, 2021 17:13
Check Empty in all Type Javascript
function isEmpty(x) {
if(Array.isArray(x)
|| typeof x === 'string'
|| x instanceof String
) {
return x.length === 0;
}
if(x instanceof Map || x instanceof Set) {
return x.size === 0;
@iammilaad
iammilaad / reactUseState.js
Created October 26, 2018 00:22
useState Hook in react
import React, {useState, Fragment} from 'react';
// React v16.7.0-alpha
export default function App(props) {
const [name, setName] = useState('user');
handleSubmit = value => {
setName(value);
}
retuen(
<Fragment>
@iammilaad
iammilaad / lazyLoadReact.js
Created October 25, 2018 23:44
React.lazy
import React, {lazy, Suspense, Fragment} from 'react';
//reactjs vestion should be 16.6.0
const Product = lazy(() => import('./Product'));
function LazyComponent() {
return (
<Suspense fallback={
<Fragment>
Loading...
</Fragment>
@iammilaad
iammilaad / pureHoc.js
Last active October 25, 2018 23:34
Pure HOC Reactjs
import { memo } from 'react';
//reactjs vestion should be 16.6.0
function List(props) {
// Component Code
}
export dafault memo(List);
@iammilaad
iammilaad / AsyncRouter.js
Last active May 2, 2018 11:01
Async Component in Router Router
import React from 'react';
import { Switch, Route } from 'react-router-dom';
import asyncFunction from './asyncFunction';
class Router extends React.Component {
render() {
return (
<Switch>
<Route
exact
@iammilaad
iammilaad / ReactAsyncComponent.js
Last active May 2, 2018 11:00
ReactAsyncComponent
import React, { Component, Fragment } from 'react';
import Nprogress from 'nprogress';
import ReactPlaceholder from 'react-placeholder';
import 'nprogress/nprogress.css';
import 'react-placeholder/lib/reactPlaceholder.css';
export default function asyncFunction(importedComponent) {
class ReactAsyncComponent extends Component {
constructor(props) {

Keybase proof

I hereby claim:

  • I am miladbruce on github.
  • I am miladbruce (https://keybase.io/miladbruce) on keybase.
  • I have a public key whose fingerprint is 07D9 64B8 96C5 9687 6B7C 1F2E 621B 1A5E 9AF2 1DDE

To claim this, I am signing this object: