Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const initialize = (component, callback1) => {
/*
Configure Cerebral and Overmind
*/
const overmind = createOvermind(config, {
// devtools:
// (window.opener && window.opener !== window) || !window.chrome
// ? false
// : 'localhost:3031',
devtools: false,
name:
'PIB material editor - ' +
(navigator.userAgent.indexOf('Chrome/76') > 0 ? 'Chrome' : 'Canary'),
logProxies: true
})
getState = path =>
path
? path.split('.').reduce((aggr, key) => aggr[key], overmind.state)
: overmind.state
getSignal = path =>
const debug = _debug('cs:app');
window.setImmediate = (func, delay) => setTimeout(func, delay);
window.addEventListener('unhandledrejection', e => {
if (e && e.reason && e.reason.name === 'Canceled') {
// This is an error from vscode that vscode uses to cancel some actions
// We don't want to show this to the user
e.preventDefault();
}
});
window.__isTouch = !matchMedia('(pointer:fine)').matches;
const overmind = createOvermind(config, {
devtools:
(window.opener && window.opener !== window) || !window.chrome
? false
: 'localhost:3031',
name:
'CodeSandbox - ' +
(navigator.userAgent.indexOf('Chrome/76') > 0 ? 'Chrome' : 'Canary'),
logProxies: true,
});
if (process.env.NODE_ENV === 'production') {
const ignoredOvermindActions = [
'onInitialize',
'server.onCodeSandboxAPIMessage',
'track',
'editor.previewActionReceived',
constructor(props) {
super(props)
const mutations = props.pageProps.mutations || []
if (typeof window !== 'undefined') {
// On the client we just instantiate the Overmind instance and run
// the "changePage" action
this.overmind = createOvermind(config)
this.overmind.actions.changePage(mutations)
} else {
// On the server we rehydrate the mutations to an SSR instance of Overmind,
// as we do not want to run any additional logic here
this.overmind = createOvermindSSR(config)
rehydrate(this.overmind.state, mutations)
}
}
// CLIENT: After initial route, on page change
import React from "react"
import { render } from "react-dom"
import App from "./components/App"
import { config } from "./overmind"
import { createOvermind } from "overmind"
import { Provider } from "overmind-react"
const overmind = createOvermind(config)
// Since we are using HtmlWebpackPlugin WITHOUT a template, we should create our own root node in the body element before rendering into it
const root = document.createElement("div")
root.id = "root"
document.body.appendChild(root)
render(
,
document.getElementById("root")
)
import { injectGlobal } from 'emotion'
import { createOvermind } from 'overmind'
import { Provider } from 'overmind-react'
import { createElement } from 'react'
import { render } from 'react-dom'
import { setConfig } from 'react-hot-loader'
import App from './components/App'
import * as iconFont from './icomoon.woff2'
import { config } from './overmind'
const overmind = createOvermind(
config,
process.env.NODE_ENV === 'production'
? {
devtools: false,
}
: {
devtools: true,
}
)
setConfig({
ignoreSFC: true, // RHL will be __completely__ disabled for SFC
pureRender: true, // RHL will not change render method
})
injectGlobal`
opacity: 1;
}
.Resizer.disabled {
cursor: not-allowed;
}
.Resizer.disabled:hover {
border-color: transparent;
}
`
window.onerror = (_, _2, _3, _4, error) => {
overmind.actions.setError(error.message)
}
const overmind = createOvermind(config, {
devtools: false,
})
const container = document.createElement('div')
container.id = 'app'
document.body.appendChild(container)
render(
,
container
)
export default ({
namespaces
}: {
namespaces: { [key: string]: Namespace };
}) => {
const config = getConfig({ namespaces, settings });
const stores = createOvermind(config, {
devtools: false
}) as any;
const mutationTree = stores.proxyStateTree.getMutationTree();
stores.state = mutationTree.state;
stores.hydrate = () => {
return mutationTree.flush().mutations;
};
return { stores, mutationTree };
};
import { createOvermind } from 'overmind';
import { createHook } from 'overmind-react';
import { initialState } from './state';
import * as actions from './actions';
import * as effects from './effects';
export const store = createOvermind({
state: initialState,
actions,
effects,
});
export const useStore = createHook();