Closed barrystaes closed 9 years ago
Indeed you are right and that was just inpired by great Alt example here :
https://github.com/goatslacker/alt/blob/master/examples/todomvc/js/components/TodoApp.react.js
Then this method should be static to component, do you have any suggestions of refactoring ?
I was just trying to understand the reason, but perhaps there is none.. if anyone reading this knows please do tell. :)
My diy kiss flux test (looks like yours) continues to work since ditching that global function: https://github.com/barrystaes/react-starter/commit/b5cfad300be474fc46c4c9225e036fd32c2839be#diff-60e809b1ec027a80a8f077712572fccb
Turns out there is a reason to have functions like this.
Apparently this is how JS objects exposed through modules can have "private" variables and functions.
Looking at this starter kit now.. and see a great example of something that intrigues me:
The controller view HomeSection.jsx has a function to load state from store.
Why is it placed not inside the component, but as a (global) function next to it? AFAIK, there is nothing outside of the component that would need to be able to call it in the global scope.