Skip to content

Instantly share code, notes, and snippets.

@bisubus
bisubus / main.js
Created August 4, 2021 09:44 — forked from bponomarenko/main.js
Custom implementation of the missing onAbort hooks in vue-router
import Vue from 'vue';
import VueRouter from 'vue-router';
import applyOnRouterAbortShim from './on-router-abort-shim';
Vue.use(VueRouter);
const router = new VueRouter(...);
applyOnRouterAbortShim(router);
@bisubus
bisubus / client.js
Created September 29, 2017 05:25 — forked from damonYuan/client.js
react server side rendering without redux (client side)
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { Router, browserHistory, useRouterHistory } from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
import { configureStore } from './app/SpreeReactStore';
import routes from './app/routes';
let state = window.__initialState__ || undefined;
@bisubus
bisubus / renderRoute.js
Created September 29, 2017 05:25 — forked from damonYuan/renderRoute.js
react server side rendering without redux (server side)
// Helper function: Loop through all components in the renderProps object // and returns a new object with the desired key
let getPropsFromRoute = (renderProps, componentProps) => {
let props = {};
let lastRoute = renderProps.routes[-1];
renderProps.routes.reduceRight((prevRoute, currRoute) => {
componentProps.forEach(componentProp => {
if (!props[componentProp] && currRoute.component[componentProp]) {
props[componentProp] = currRoute.component[componentProp];
}
});
@bisubus
bisubus / Portal.js
Created September 25, 2017 11:11 — forked from lixiaoyan/Portal.js
React 16: Portal
import React from "react";
import PropTypes from "prop-types";
import { createPortal } from "react-dom";
class Portal extends React.Component {
static propTypes = {
children: PropTypes.node,
};
state = { mounted: false };
@bisubus
bisubus / entry.js
Created September 24, 2017 08:25 — forked from lixiaoyan/entry.js
React 16: ReactDOM.hydrate(...)
import React from "react";
import ReactDOM from "react-dom";
import { AppContainer } from "react-hot-loader";
import App from "./App";
const render = (hydrate = false) => {
const container = document.querySelector("#app");
const element = (
<AppContainer>