Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default ({atomicNumber, chunks}) => {
history.push(`/${atomicNumber||''}`)
linkHistoryToStore(store)
const styleTagString = collectStyles()
// HACK: Pass FullElement down for render
global.fullElementHack = atomicNumber ? new FullElement(atomicNumber, fullElements[atomicNumber]) : {}
const renderedAppString = renderToString()
const stateScriptString = `window.dryState = ${JSON.stringify(store.getState()).replace(/)
console.log('⚡️', atomicNumber)
return ` ${documentString}`
}
BakedDoc.load(data, (err, doc, file) => {
if (err) return done(err)
console.log('loaded data. rendering')
var embedData = JSON.stringify(data).replace(/) // doc
console.log('rendered')
done(null, `
<title>${data[0].content} | Notablemind</title>
html += ReactDOMServer.renderToStaticMarkup(component);
} else {
// render the redux wrapped component
if (createOptions.reduxStoreInitiator) {
// add redux provider
var Provider = require('react-redux').Provider;
var initStore;
try {
initStore = require(createOptions.reduxStoreInitiator);
if (initStore.default) {
initStore = initStore.default;
}
var store = initStore(data);
var wrappedComponent = React.createElement(Provider, { store: store }, component);
// render the component
html += ReactDOMServer.renderToString(wrappedComponent);
} catch (err) {
return done(err);
}
} else {
// render the component
html += ReactDOMServer.renderToString(component);
}
// the `script` tag that gets injected into the server rendered pages.
// https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.233_-_JavaScript_Escape_Before_Inserting_Untrusted_Data_into_JavaScript_Data_Values
var script = '
app.get('/', (req, res) => {
// Loads a template.
const pathToHtml = path.join(__dirname, './views/index.html')
const template = fs.readFileSync(pathToHtml, 'utf8')
// Inserts a rendered react component to the loaded template (server-side rendering).
const renderedHelloWorld = renderToString()
const page = template.replace('', renderedHelloWorld)
res.status(200).send(page)
})
const getServerHTML = (appHtml, dehydratedState = null) => {
return `${ ReactDOMServer.renderToString(
) }`;
};
function renderPageToString(page) {
return `${renderToString(page)}`;
}
const fatalErrorOutput = (errorComponent, store) => {
return ReactDOM.renderToString(
);
};
const stringsPromise = store.runSaga(rootSaga).toPromise().then(() => {
const html = renderToString(rootComp)
const css = sheets.toString()
const state = JSON.stringify(store.getState())
return { html, css, state }
})
render() {
const { assets, component, store } = this.props;
const content = component ? ReactDOM.renderToString(component) : '';
return (
<div id="content">
</div>
componentWillMount() {
const draft = this.drafts[this.getIdentifier()]
if(draft) {
new Noty({
closeWith: ['click', 'button'],
layout: 'topRight',
progressBar: true,
theme: 'semanticui',
text: ReactDOMServer.renderToString(
<header>
Draft Loaded
chainBB has loaded unsubmitted draft you had for this forum/thread. Hit cancel to delete this draft.
</header>
),
type: 'success',
timeout: 8000
}).show();
this.setState({preview: draft || {}})
}
}