Closed command-tab closed 9 years ago
Over in the Alt repo a feature was just landed which lets you define data fetching needs at the component level, they are then populated into the stores automatically: https://github.com/goatslacker/alt/blob/master/test/alt-iso-test.js#L84
Ooh, how very Relay/GraphQL like. That sounds lovely! Is that decorator @-style syntax an ES7 thing I'll have to enable on Babel and webpack?
(It's occasionally feeling like this old Angular guy bit off more than he could chew to learn React, Flux, and ES6 all at once! Things sure have changed in the last year.)
Yeah it's decorator syntax: https://github.com/wycats/javascript-decorators
Totally optional. They're just function calls.
OK, last question, I swear! Then I'll close this :)
When I use AltContainer inside an array .map()
call to produce an array of components from an array of props, AltContainer seems to be resolving every item to the last item in the array, resulting in duplicate output instead of unique output consistent with each array item. Yet, if I omit usage of AltContainer and use this.props.whatever
directly, the output is correct.
Have you seen anything like that before?
(I've taken alt-iso-test
from the alt repo, split up the files, and added a minimal express server to view rendered markup in a browser. The issue I'm running into seems to be around here.)
Thanks again!
Nevermind, I got it going!
I'm still learning React and Flux (with alt and iso), but I'm wondering if there's a way to approach the initial server-side render without having to populate the stores manually.
Looking at your react-router-flux example, I see you (pretending to) fetch data from a backend API and populate a store with it. Is there an example that you know of that does this automatically by using react-router load the route and any nested routes, call the initial actions, and populate the stores like one would client-side? I guess you'd have to wait for all store data-fetching promises to resolve first, but I'm unsure of how you'd enumerate them, wait, and only then serialize the stores for the initial markup response.
Thanks so much!