Skip to content

Instantly share code, notes, and snippets.

@jxnblk
Created May 24, 2018 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jxnblk/3abb310c1c5e0803592eac6e4cf35148 to your computer and use it in GitHub Desktop.
Save jxnblk/3abb310c1c5e0803592eac6e4cf35148 to your computer and use it in GitHub Desktop.
diff --git a/src/bunnies.examples.js b/src/bunnies.examples.js
index f8a9f55..e03c5b3 100644
--- a/src/bunnies.examples.js
+++ b/src/bunnies.examples.js
@@ -1,3 +1,3 @@
import {bunnies} from './bunnies'
-export const capitalBunnies = bunnies.map(b => b.toUpperCase())
+export const capitalBunnies = bunnies.map(b => 'hello, ' + b.toUpperCase())
diff --git a/src/index.js b/src/index.js
index 7b09172..e7eb260 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,10 +1,11 @@
const context = require.context('.', true, /\/.*\.examples\.js/)
-console.log(context.keys())
+console.log(context.keys(), context.id)
const root = document.getElementById('root')
function renderThings() {
+ console.log('renderThings')
const allThings = context.keys().map(path => context(path))
root.innerHTML = `<pre>${JSON.stringify(allThings, null, 2)}</pre>`
}
@@ -13,8 +14,9 @@ renderThings()
if (module.hot) {
// what I want to be able to do:
- module.hot.accept(context.keys(), () => {
+ module.hot.accept(context.id, () => {
// this is never called
+ console.log('hot')
renderThings()
})
// I've also tried
@@ -22,10 +24,10 @@ if (module.hot) {
// module.hot.accept(context.id, () => {})
// not even this works.
- module.hot.accept('./bats.examples.js', () => {
- // this is never called
- console.log('bats!')
- })
+ // module.hot.accept('./bats.examples.js', () => {
+ // // this is never called
+ // console.log('bats!')
+ // })
// These don't work. I get a full page refresh with a warning that the changed
// file is not accepted and a gnarly error like:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment