mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-25 23:05:23 +00:00
feat: get hot reloading working for js code snippets
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
const crypto = require(`crypto`);
|
||||
|
||||
// docblock goes here
|
||||
const createContentDigest = obj =>
|
||||
crypto
|
||||
.createHash(`md5`)
|
||||
@@ -9,7 +8,7 @@ const createContentDigest = obj =>
|
||||
|
||||
// Store code snippets in GraphQL for the home page examples.
|
||||
// Snippets will be matched with markdown templates of the same name.
|
||||
exports.onCreateNode = async ({node, loadNodeContent, actions}) => {
|
||||
exports.onCreateNode = async ({actions, node, loadNodeContent}) => {
|
||||
const {createNode} = actions;
|
||||
const {absolutePath, ext, name, relativeDirectory, sourceInstanceName} = node;
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ class CodeEditor extends Component {
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
if (prevState.compiled !== this.state.compiled) {
|
||||
this._render();
|
||||
} else if (this.props.code !== prevProps.code) {
|
||||
this.setState({
|
||||
code: this.props.code,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user