3 ms·
In general the React approach works best if you are willing to build out a handful of utilities on your own sometimes, rather than always choosing from pre-exis
by guscost 10y ago
In general the React approach works best if you are willing to build out a handful of utilities on your own sometimes, rather than always choosing from pre-existing open-source solutions. You don't need React Router. You don't need React-Redux. Heck, you don't always need Redux, you can just throw a state object on the window (or make a state module or whatever you do these days).
Here's a React 15 app in a single HTML file, using ES5 and the old in-browser JSXTransformer:
https://gist.github.com/guscost/27736c5f0913184695492ac40fd3a19c https://gist.github.com/guscost/27736c5f0913184695492ac40fd3...
- rikkus 10y agoI had high hopes there, but I don't see an app, I just see enough boilerplate to put a <span>Hello, world!</span> into the DOM, which could have been done by just writing that into HTML. I can understand what it's doing, but I don't think it's a good example of how you can write an actual app without the parts people are mentioning.
- guscost 10y agoYou'd include all the modules as separate script files. Each script file is a revealing module[0] that exports its API to a global variable. If you're interested I could put together a more complete boilerplate. I don't actually use this approach much in front-end work these days, but it can be nice to work with just text editor and browser. As for building it, you're on your own. You could run jsx from the command line, concat them all together and minify. http://stackoverflow.com/questions/5647258/how-to-use-revealing-module-pattern-in-javascript http://stackoverflow.com/questions/5647258/how-to-use-reveal...
- darth_mastah 10y agoI may be wrong, but I use webpack to remove exactly the the pain point of running jsx from the command line, concatenating files and minifying them. It does good job there and saves me time.
- guscost 10y agoIt's a good solution, but webpack can be overwhelming to newcomers, and it sometimes can lock you into working with associated dev tools like webpack-dev-server and all the various loaders.
- andrewingram 10y agohttps://www.depop.com/ https://www.depop.com/ = React + Relay + React Router (probably not needed, might switch to Next when I upgrade to Relay Modern). Redux is technically in the codebase, but for such a minor feature that I think I'd now be comfortable removing it. I appreciate the site is relatively simple, but honestly React + Relay + [insert router here], is sufficient to build this out to something of relatively high complexity. Obviously, I have more dependencies than this (JavaScript lol), but they're mainly ones for solving very specific requirements, rather than key architectural libraries.