Skip to content

Instantly share code, notes, and snippets.

View kdichev's full-sized avatar
⚛️
useEffect(() => { setWorking(true) }, [])

Konstantin Dichev kdichev

⚛️
useEffect(() => { setWorking(true) }, [])
View GitHub Profile
let mix = require('laravel-mix');
var Visualizer = require('webpack-visualizer-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
import React, { Component } from 'react';
export default function asyncComponent(importComponent) {
class AsyncComponent extends Component {
constructor(props) {
super(props);
this.state = {
const Moment = require('moment')
const MomentRange = require('moment-range')
const moment = MomentRange.extendMoment(Moment);
const fetch = require('node-fetch')
const getItems = () => {
return fetch(MY_API_LINK, {
method: 'post',
headers: {
'Content-Type': 'application/json',
@kdichev
kdichev / index.js
Created February 3, 2018 11:29
Hero component
import React from 'react'
import styled from 'styled-components'
import Logo from './../bigLogo.svg'
import { media } from './../media'
const theme = {
backgroundColor: {
primary: '#f8f4eb'
},
textColor: {
@kdichev
kdichev / index.js
Created February 10, 2018 18:53
async app
import React, { Component } from 'react'
import { withWeb3 } from './../Web3Provider'
import { BlockCard } from './../BlockCard/BlockCard'
import { CardsContainer } from './primitives'
import ContentLoader from 'react-content-loader'
const Loader = props => (
<ContentLoader
height={97}
@kdichev
kdichev / index.js
Last active February 14, 2018 11:28
import React from 'react'
// simple stateless component (children is reserved word)
const DisplayHelloWorld = (props) => (
<div>
message: {props.children}
name: {props.name}
</div>
)
import { createStore, applyMiddleware, compose } from "redux";
import thunkMiddleware from "redux-thunk";
const configureStore = (initialState) =>
createStore(
// here reducers
// REDUCERS.js
persistedState,
compose(
applyMiddleware(
@kdichev
kdichev / js
Created April 8, 2018 10:04
reducers.js
import { combineReducers } from "redux";
const initialState = {
hi: "hi"
};
export const theReducer = (state = initialState, action) => {
switch (action.type) {
case "SOMETHING_HAPPENING":
return { ...state, hi: "bye" };
import { connect } from "react-redux";
const mapStateToProps = ({
theReducer: { city, humidity, temperature, wind }
}) => ({
city,
humidity,
temperature,
wind
});
const asyncAction = (dataMaybe) => async (dispatch, getState) => {
// u can dispatch all kinds of actions here according to outcome
dispatch({type: "FETCHING_START"}
// if u need to use store data but can be passed as arg from react component when invoking
const store = getState().theReducer
const response = await myFetchFunction()
if (response) {
dispatch({type: "FETCHING_SUCCESS", payload: {response}}