dai-shi / react-hooks-global-state

[NOT MAINTAINED] Simple global state for React with Hooks API without Context API
https://www.npmjs.com/package/react-hooks-global-state
MIT License
1.1k stars 62 forks source link

feature/add-thunk-example-script add script to run thunk example #24

Closed tgrrr closed 4 years ago

tgrrr commented 5 years ago

Add back "examples:thunk": "DIR=08_thunk webpack-dev-server", to package.json to run thunk example

dai-shi commented 5 years ago

Hi, thanks for opening this up. As far as I remember, there was some issue in running the thunk example locally. Does it run for you?

tgrrr commented 5 years ago

It worked for me. However, I'll test it. Do you have a link to the thunk bugs?

dai-shi commented 5 years ago

It's not a bug. It works with CRA. (Run it in the examples/* folder or in codesandbox)

Maybe it's fixed with npm run examples:* too, because I recently updated all devDependencies. I'll try it in my machine later.

dai-shi commented 5 years ago

Hmm, it doesn't work for me. If I remove the file examples/08_thunk/tsconfig.json, it works. But just running DIR=08_thunk webpack-dev-server gives me, the following error in the browser.

./examples/08_thunk/src/App.tsx 8:32
Module parse failed: Unexpected token (8:32)
File was processed with these loaders:
 * ./node_modules/ts-loader/index.js
You may need an additional loader to handle the result of these loaders.
| var Counter_1 = require("./Counter");
| var Person_1 = require("./Person");
> var App = function () { return (<react_1.StrictMode>
|     <state_1.GlobalStateProvider>
|       <h1>Counter</h1>

./examples/08_thunk/src/App.tsx
[tsl] ERROR in /.../react-hooks-global-state/examples/08_thunk/src/App.tsx(6,21)
      TS6142: Module './Counter' was resolved to '/.../react-hooks-global-state/examples/08_thunk/src/Counter.tsx', but '--jsx' is not set.

...

As far as I remember examples/08_thunk/tsconfig.json is required for codesandbox to run the 08_thunk example. I need some configuration to let it read ./tsconfig.json instead of examples/08_thunk/tsconfig.json.

I wonder how you made it work. 🤔

dai-shi commented 4 years ago

I was able to remove 08_thunk/tsconfig.json and it's working now.