-
Notifications
You must be signed in to change notification settings - Fork 10
Upgrade react/react-dom to 15.6.1 and react-router to 4.1.1 #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mjhamm75
wants to merge
1
commit into
tuxsudo:master
Choose a base branch
from
mjhamm75:feature/reactUpgrade
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,85 @@ | ||
import React from 'react'; | ||
import docTemplate from './HTML.js'; | ||
import { renderToString } from 'react-dom/server'; | ||
import { match, RouterContext } from 'react-router'; | ||
import { StaticRouter } from 'react-router'; | ||
import { Provider } from 'react-redux'; | ||
import Helmet from 'react-helmet'; | ||
import {encode} from '@tuxsudo/b64'; | ||
import routes from './routes.js'; | ||
import getStore from './store.js'; | ||
import { minify } from 'html-minifier'; | ||
import { resolve } from './hocs/ss-resolve'; | ||
// import { resolve } from './hocs/ss-resolve'; | ||
import {selectHTTPResponseCode} from './store.js'; | ||
|
||
import * as env from './env.js'; | ||
|
||
|
||
export default (req, res, next) => { | ||
match({ routes, location: req.url }, (err, redirect, props) => { | ||
|
||
if (err) { | ||
return next(err); | ||
|
||
} else if (redirect) { | ||
res.redirect(redirect.pathname + redirect.search) | ||
|
||
} else if (props) { | ||
const store = getStore(); | ||
|
||
resolve(props, store) | ||
.then(() => { | ||
const initialState = store.getState(); | ||
const httpStatus = selectHTTPResponseCode(initialState); | ||
const opaqueStateString = encode(JSON.stringify(initialState)); | ||
|
||
const content = renderToString( | ||
<Provider store={store}> | ||
<RouterContext {...props} /> | ||
</Provider> | ||
); | ||
|
||
res.status(httpStatus).send( | ||
minify( | ||
docTemplate({ | ||
...(Helmet.rewind()), | ||
content, | ||
initialState: opaqueStateString, | ||
env, | ||
base_path: env.APP_WEB_BASE_PATH | ||
}), | ||
{ collapseWhitespace: true, removeAttributeQuotes: true } | ||
) | ||
); | ||
}).catch(next); | ||
|
||
} else { | ||
res.status(404).send('Not Found') | ||
} | ||
}) | ||
const store = getStore(); | ||
|
||
const content = renderToString( | ||
<StaticRouter context={{}} location={req.url}> | ||
<Provider store={store}> | ||
{routes} | ||
</Provider> | ||
</StaticRouter> | ||
) | ||
|
||
const initialState = store.getState(); | ||
const httpStatus = selectHTTPResponseCode(initialState); | ||
const opaqueStateString = encode(JSON.stringify(initialState)); | ||
|
||
res.status(httpStatus).send( | ||
minify( | ||
docTemplate({ | ||
...(Helmet.rewind()), | ||
content, | ||
initialState: opaqueStateString, | ||
env, | ||
base_path: env.APP_WEB_BASE_PATH | ||
}), | ||
{ collapseWhitespace: true, removeAttributeQuotes: true } | ||
) | ||
); | ||
// match({ routes, location: req.url }, (err, redirect, props) => { | ||
|
||
// if (err) { | ||
// return next(err); | ||
|
||
// } else if (redirect) { | ||
// res.redirect(redirect.pathname + redirect.search) | ||
|
||
// } else if (props) { | ||
// const store = getStore(); | ||
|
||
// resolve(props, store) | ||
// .then(() => { | ||
// const initialState = store.getState(); | ||
// const httpStatus = selectHTTPResponseCode(initialState); | ||
// const opaqueStateString = encode(JSON.stringify(initialState)); | ||
|
||
// const content = renderToString( | ||
// <Provider store={store}> | ||
// <RouterContext {...props} /> | ||
// </Provider> | ||
// ); | ||
|
||
// res.status(httpStatus).send( | ||
// minify( | ||
// docTemplate({ | ||
// ...(Helmet.rewind()), | ||
// content, | ||
// initialState: opaqueStateString, | ||
// env, | ||
// base_path: env.APP_WEB_BASE_PATH | ||
// }), | ||
// { collapseWhitespace: true, removeAttributeQuotes: true } | ||
// ) | ||
// ); | ||
// }).catch(next); | ||
|
||
// } else { | ||
// res.status(404).send('Not Found') | ||
// } | ||
// }) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
import React from 'react'; | ||
import { Route, IndexRoute } from 'react-router'; | ||
import { Route, Switch } from 'react-router-dom'; | ||
import App from './containers/app.js'; | ||
import Home from './containers/home.js'; | ||
import NotFound from './containers/not-found.js'; | ||
import {APP_WEB_BASE_PATH} from './env.js'; | ||
|
||
const routes = ( | ||
<Route path={`${APP_WEB_BASE_PATH||'/'}`} component={App} > | ||
<IndexRoute component={Home} /> | ||
<Route path="*" component={NotFound} /> | ||
</Route> | ||
<Route | ||
path="/" | ||
render={props => ( | ||
<Switch> | ||
<Route exact path="/" component={Home} /> | ||
<Route path="*" component={NotFound} /> | ||
</Switch> | ||
)} | ||
/> | ||
); | ||
|
||
export default routes; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To update to RR4, we will need to enable the server side functionality first and so this
resolve
functionality needs to be enabled or replicated...