Skip to content

Instantly share code, notes, and snippets.

View matijagalina's full-sized avatar

Matija Galina matijagalina

View GitHub Profile
@matijagalina
matijagalina / custom-prompt-example.jsx
Created December 31, 2019 15:00
Custom Prompt react-router
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-dom';
// "react-router": "^5.1.2"
// "react-router-dom": "^5.1.2"
<BrowserRouter
getUserConfirmation={(message, callback) => (
CustomPromptComponent(message, callback)
### Keybase proof
I hereby claim:
* I am matijagalina on github.
* I am mgalina (https://keybase.io/mgalina) on keybase.
* I have a public key ASCgRLvrkyavuERNgj8WUiwtSh6wurbRz5fYaPmdAMMKKAo
To claim this, I am signing this object:
import axios from 'axios';
axios.defaults.xsrfCookieName = 'csrftoken';
axios.defaults.xsrfHeaderName = 'x-csrftoken';
axios.interceptors.response.use((response) => {
if (response.status === 401
|| response.status === 403) {
window.location.href = '/login'; // eslint-disable-line no-undef
}
return response;
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import get from 'lodash.get';
import ProfileDetails from '../components/ProfileDetails';
import { refreshUser } from 'redux/user/actions';
const ProfileContainer = ({
refreshUserAction,
user,
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'development',
entry: './src/index.js',
output: {
filename: 'bundle.js',
},
module: {
rules: [
@matijagalina
matijagalina / auth_hoc_boilerplate.js
Created May 5, 2019 08:37
React auth HOC boilerplate test example
// boilerplate for HOC
// import React, { Component } from "react";
// export default ChildComponent => {
// class ComposedComponent extends Component {
// render() {
// // pass the props
// return <ChildComponent {...this.props} />
// }
// }
@matijagalina
matijagalina / redux_middleware_boilerplate.js
Created May 5, 2019 08:36
Redux middleware boilerplate test example
// boilerplate for middleware
export default ({ dispatch }) => next => action => {
// add new property on action object
const newAction = { ...action, test: 'test' };
// condition to skip this middleware
const somethingWrong = false;
if(somethingWrong) {
// call next middleware
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { applyMiddleware, combineReducers, createStore } from 'redux';
import thunk from 'redux-thunk';
import App from './components/App';
import api from '../api';
// asynchronous action using async/await syntax
const getUser = () => async dispatch => {
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { combineReducers, createStore } from 'redux';
import App from './components/App';
const userData = { firstname: 'Pham', lastname: 'Nuwem' };
// action
const getUser = () => ({
...
"eslintConfig": {
"extends": [
"airbnb"
],
"rules": {
"comma-dangle": 1,
"import/no-unresolved": 0,