prodo-dev / prodo

Prodo is a React framework to build apps faster.
https://docs.prodo.dev
MIT License
114 stars 5 forks source link

Better errors when using ctx outside action or component #34

Open coffee-cup opened 5 years ago

coffee-cup commented 5 years ago

If you have the transpiler setup and have

import { state } from "./model";

console.log(state.foo);

const myAction = () => {
  state.foo += 1;
}

you will get a runtime error say that you can't read foo of undefined. Instead of removing the state import after transpilation, we should keep it and make everything on the imported ctx a proxy that will show a nice error message.