Skip to content
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

Add call to fetchSiteData when reloadClientData is called in runDevserver.js #1409

Merged
merged 6 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- Fix Webpack stats output in environment that don't support color ([#1370](https://github.com/react-static/react-static/pull/1370))
- Fix HMR in sass plugin ([#1400](https://github.com/react-static/react-static/pull/1400))
- Fix using dots in routes. ([#1365](https://github.com/react-static/react-static/pull/1365))
- Fix reloadClientData to call fetchSiteData runDevserver.js ([#1409](https://github.com/react-static/react-static/pull/1409))

## 7.2.2

Expand Down
6 changes: 4 additions & 2 deletions packages/react-static/src/static/webpack/runDevServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ async function runExpressServer(state) {
port: messagePort,
})
})

// Since routes may change during dev, this function can rebuild all of the config
// routes. It also references the original config when possible, to make sure it
// uses any up to date getData callback generated from new or replacement routes.
Expand All @@ -128,13 +129,13 @@ async function runExpressServer(state) {
)}`,
async (req, res, next) => {
// Make sure we have the most up to date route from the config, not
// an out of dat object.
// an out of date object.
let route = latestState.routes.find(d => d.path === routePath)
try {
if (!route) {
const err = new Error(
`Route could not be found for: ${routePath}

If you removed this route, disregard this error.
If this is a dynamic route, consider adding it to the prefetchExcludes list:

Expand Down Expand Up @@ -226,6 +227,7 @@ If this is a dynamic route, consider adding it to the prefetchExcludes list:
const socket = io()

reloadClientData.current = async () => {
latestState = await fetchSiteData(latestState)
socket.emit('message', { type: 'reloadClientData' })
}

Expand Down