Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit bf4e440

Browse files
committed
fix(gatsby-theme-docz): hot reload
1 parent bc1303d commit bf4e440

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

core/docz/src/utils/createState.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ export function create<T = any>(initial: T): State<T> {
4141
public componentWillUnmount(): void {
4242
listeners.clear()
4343
}
44-
public shouldComponentUpdate(nextProps: any, nextState: any): boolean {
45-
return !equal(this.state, nextState)
46-
}
4744
public render(): React.ReactNode {
4845
return (
4946
<ctx.Provider value={this.state}>{this.props.children}</ctx.Provider>

core/gatsby-theme-docz/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"gatsby-plugin-compile-es6-packages": "^1.0.6",
2929
"gatsby-plugin-manifest": "^2.0.17",
3030
"gatsby-plugin-react-helmet": "^3.0.6",
31+
"lodash": "^4.17.11",
3132
"prop-types": "^15.7.2",
3233
"react": "^16.8.2",
3334
"react-dom": "^16.8.2",

core/gatsby-theme-docz/src/node/createPagesStatefully.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ const path = require('path')
22
const chokidar = require('chokidar')
33
const { Entries } = require('docz-core')
44
const { parseConfig } = require('../utils/parseConfig')
5+
const { get } = require('lodash/fp')
56

67
const getEntry = async (filepath, entries) => {
78
const map = await entries.get()
8-
return map[filepath]
9+
return get(filepath, map)
910
}
1011

1112
const mountRoute = (base = '/', route) => {
@@ -25,8 +26,8 @@ module.exports = async ({ store, actions }, opts) => {
2526
})
2627

2728
const handleCreatePage = async filepath => {
28-
const component = path.join(paths.root, filepath)
2929
const entry = await getEntry(filepath, entries)
30+
const component = path.join(paths.root, filepath)
3031

3132
if (entry) {
3233
createPage({
@@ -50,10 +51,16 @@ module.exports = async ({ store, actions }, opts) => {
5051
}
5152
}
5253

54+
const allEntries = await entries.get()
55+
await Promise.all(
56+
Object.values(allEntries).map(async value => {
57+
handleCreatePage(value.filepath)
58+
})
59+
)
60+
5361
return new Promise((resolve, reject) => {
5462
watcher
5563
.on('add', handleCreatePage)
56-
.on('change', handleCreatePage)
5764
.on('unlink', handleDeletePage)
5865
.on('ready', () => resolve())
5966
.on('error', err => reject(err))

0 commit comments

Comments
 (0)