4 ms·
Here are my 2 cents: 1. Don't use a boilerplate. Not even create-react-app. Learn webpack and npm and TS / Babel. It's not that hard. 2. If you havn't yet, ta
by JTenerife 10y ago
Here are my 2 cents:
1. Don't use a boilerplate. Not even create-react-app. Learn webpack and npm and TS / Babel. It's not that hard.
2. If you havn't yet, take a second look at MobX. I got it once I realized that I can organize my state just as I love it with Redux (normalized and update strictly through actions). With MobX you don't need Reselect.
3. Even though the React community seems to favor ES6, at least give Typescript a serious try.
- statictype 10y agoTypescript with react is awesome and I probably would find it difficult to go back to react without it. Getting type information in your editor when you are several levels deep in components is very useful. My only complaint is trying to figure out how to properly work with 3rd party react modules within typescript's own namespace system
- tomduncalf 10y ago> My only complaint is trying to figure out how to properly work with 3rd party react modules within typescript's own namespace system Could you be more specific about the issue you're having here? Might be able to help
- cheapsteak 10y ago>1. Don't use a boilerplate. Not even create-react-app. Learn webpack and npm and TS / Babel. It's not that hard. I can't say that I agree with this Hunkering down to learn build tools will probably yield the lowest ROI compared to nearly anything else you could be doing They're nice to know, sure, but you'll pick them up along the way as you use and modify them As you said, not that hard :) And +1 on MobX. Bee's knees
- geewee 10y agoHow did you get typescript working properly with redux? I never could figure out how to get proper types in my reducers or HMR to work.
- tomduncalf 10y agoYou end up doing a bit of explicit casting in places to ensure type safety, but it works. Little discussion I had about this with someone on Twitter which may or may not be relevant: https://twitter.com/tomduncalf/status/804002710878044160 https://twitter.com/tomduncalf/status/804002710878044160 I should write a blog post about Redux and Typescript - it would be good to know which bits you are struggling with. HMR works fine with Typescript, you do need to use Babel as well though. This post I wrote should get you up and running: http://blog.tomduncalf.com/posts/setting-up-typescript-and-react/ http://blog.tomduncalf.com/posts/setting-up-typescript-and-r..., it is a little outdated (1.9 vs 2.1) but I don't think any major changes should be needed to make it work with newer versions. Unfortunately, HMR (v3 beta) doesn't play nice with react-router as far as I can tell, so I have given up on it for now. I really miss it so I hope someone knowledgable finds time to focus on getting it working better soon!
- geewee 10y agoThat's a really helpful blog post, actually. I thin the general pain points are the same as in your twitter discussion - the reducers quickly start feeling clunky with explicit casts or using two lines to export a constant for the switch statement. It's obviously a possibility to just forego type-safety in that part, but it'd be a shame. Another general pain point (apart from the fact that a lot of the guides you find seem reasonably outdated) is the general build setup. Your guide seems really good, but generally setting up react redux and typescript is a bit of a jungle. If you do end up writing a post, please let me know!
- Zalastax 10y agoI've not written any blog about it but I have it working in a repo [1]. The webpack config and src/model are what's most interesting for you :) To sum it up: combineReducers is templated so make an interface for your state (this is wonderful). HMR works with react-hot-loader 3 and without babel, but the documentation is lacking. [1]: https://github.com/Zalastax/openschedule https://github.com/Zalastax/openschedule
- 10y ago
- Raphmedia 10y ago> 3. Even though the React community seems to favor ES6, at least give Typescript a serious try. Could you give some arguments? I'm a big ES6 fan and I can't think of a good reason to use Typescript over it.
- insin 10y ago> Even though the React community seems to favor ES6, at least give Typescript a serious try. What's the story with dipping your toe into TypeScript on existing projects? I'm using Webpack and babel-loader, so I'm not interested in using the TypeScript compiler itself, having to renaming files to .ts, or using a different extension for files which contain JSX, but I'd still like to try TypeScript on a few modules. Is that possible? Flow seems much easier to dip into, but I haven't tried either in anger yet.