Skip to content

Instantly share code, notes, and snippets.

View desphilboy's full-sized avatar

Iman Dezfuly desphilboy

  • Melbourne Australia
View GitHub Profile
import { compose } from 'redux';
import { connect } from 'react-redux';
import withInit from '../../higher-order/with-init';
import withProps from '../../higher-order/with-props';
import {
mapStateToProps,
mapDispatchToProps,
extraProps,
callTypeApi,
callTypeApiNeeded,
import 'regenerator-runtime/runtime';
/**
* @param { object or function } dependencyMap maps dependencies into sideEffec parameter names. If it is
* a function will be called with Redux state and dispatch if non-function object will be added to
* parameters as is
*
* @param { function } sideEffect is a function that does the actual work. It will be called
* with all the parameters including mapped ones and the third param.
*
* @param { object } params additional parameters passed by caller of the effect. the params
import React, { Component } from 'react';
import { getComponentName, isValidFn } from '../utils.js';
export function withInit(init, callInitLogic, inProgressLogic, Spinner) {
return BaseComponent =>
class extends Component {
static getDerivedStateFromProps(props, state) {
const callInit = !!(
callInitLogic && (typeof callInitLogic === 'function' ? callInitLogic(props) : callInitLogic)
);
import React from "react";
import { getComponentName } from "../utils";
/* adds some more props on the component to perserve component purity and independence.
* can be called on a component only once ( not cascadable )
* Params:
* @extraProps is an mapping object or function retruning a mapping object which contains new params.
* if is a funcion, will be called with existing props.
* @BaseComponent is the component to be decorated with more props
* @props are the existing props passed by parent
import React from "react";
import { connect } from "react-redux";
import { Field, reduxForm } from "redux-form";
import { useHistory } from "react-router-dom";
import { css } from "@emotion/core";
import { ClipLoader, ClockLoader } from "react-spinners";
import {
setPetName,
setPetType
} from "../../redux/reducers/pageInfo.reducer.js";
@desphilboy
desphilboy / details-view.js
Last active March 9, 2020 12:14
sample code wellcome page
import React from "react";
import { connect } from "react-redux";
import { Field, reduxForm } from "redux-form";
import { useHistory } from "react-router-dom";
import { css } from "@emotion/core";
import { ClipLoader, ClockLoader } from "react-spinners";
import {
setPetName,
setPetType
} from "../../redux/reducers/pageInfo.reducer.js";

Why I hate TypeScript

Warning: These views are highly oppinated and might have some slightly incorrect facts. My experience with typescript was about 2 weeks in Node and a week in angular2.

Not Standard

TypeScript is implementing their own take on JavaScript. Some of the things they are writing will likely never make it in an official ES* spec either.

Technologies that have competing spec / community driven development have a history of failing; take: Flash, SilverLight, CoffeeScript, the list goes on. If you have a large code base, picking TypeScript is something your going to be living with for a long time. I can take a bet in 3 years JavaScript will still be around without a doubt.

Its also worth noting that they have built some things like module system and as soon as the spec came out they ditched it and started using that. Have fun updating!