News for hackers. Stuff that matters.
Re:Create React App 4.0 by mrath on Friday October 23, 2020 @03:42PM (#24873083)
I have a hobby project in react which I started using CRA. It only have few screen but uses material UI and few other libs so the minified bundle size already over 700k without splitting. In dev the refreshes became slow to the point where I have wait a few seconds to see result after I change a file in IntelliJ. So I wanted to give snowpack a try, and the results are amazing, In a blink of eye the browser screen is updated and state is preserved.

I read the linked issue on react-refresh on the release note, but no idea if it fast enough or not.

Re:Create React App 4.0 by whb07 on Friday October 23, 2020 @03:57PM (#24873299)
For the love of all mighty, if you happen to use the TS template DO NOT FOR A SECOND assume you’re using it in strict mode.

For whatever reason CRA has a different hidden env var flag that controls this even though you have a “strict: true” in your tsconfig file.

Re:Create React App 4.0 by andyfleming on Friday October 23, 2020 @06:29PM (#24874998)
This may have to do with Babel compiling typescript. It might run the type-checking separately and compile regardless of if it passes.
Re:Create React App 4.0 by whb07 on Saturday October 24, 2020 @08:41AM (#24878845)
I jumped into a greenfield project that had been already polluted and “using” TS. The build was still running with a 1/0 and other explicitly broken code somehow.
Re:Create React App 4.0 by lucasmullens on Friday October 23, 2020 @05:34PM (#24874463)
I'm curious how this compares to Next.js. Next.js has had fast refresh for a while, and works great as an all-in-one solution for React websites.

I think the main difference is CRA has the concept of "ejecting", allowing you to avoid interacting with config files until you really need to customize how the build works.

Re:Create React App 4.0 by dbbk on Friday October 23, 2020 @07:03PM (#24875301)
Next.js is severely restricted by its proprietary router. CRA has the downside of not supporting server rendering, but you can at least use the standard react-router.
Re:Create React App 4.0 by flak48 on Saturday October 24, 2020 @09:31AM (#24879108)
Yep. Lack of support for nested routes is what's keeping me away from Next.js too. A tab view that doesn't rerender the whole page requires jumping through many unofficial hoops with Next.js.

Even standard patterns like having seperate components for page header, sidebar that doesn't rerender the main content section feels very hacky with Next.js, and that too after digging through many people's blogs to read how they accomplished that.

I guess next.js really wants you to ditch the whole SPA idea atleast when it comes to routing.

I hope folks also explore more moderate patterns like server rendering only the first page load (either with react dom or using state hydration) or exploring better separation of client bundles too, and figure out what works best for them. Rather than sticking to whatever next.js or CRNA are set up for by default

Re:Create React App 4.0 by chrstphrknwtn on Saturday October 24, 2020 @02:35AM (#24877396)
I'm curious about restrictions of the next.js router compared to the standard react-router, are there specific serious restrictions you've experienced?

I've found the next router pretty easy to deal with, and have been writing less code to achieve the same things over time as next.js matures.

Re:Create React App 4.0 by dbbk on Saturday October 24, 2020 @06:33AM (#24878261)
Next doesn’t support nested routes and layouts. So if you have, for example, a page that has a a sidebar for a master/detail view, when you load the nested page it blows away the whole DOM and has to render the whole page again, meaning you lose your scroll positions and anything else you want to persist across pages.

React Router on the other hand lets you render subroutes directly into an ‘outlet’, maintaining the DOM state outside of it.

This is a super common pattern when you’re building something like an admin dashboard app which I do often.

Re:Create React App 4.0 by bhl on Friday October 23, 2020 @08:33PM (#24875869)
Both the standard react router and nextjs framework are open source.
Re:Create React App 4.0 by cercatrova on Friday October 23, 2020 @11:45PM (#24876778)
So what? If NextJS doesn't support another router, you're not gonna patch it in unless you want to continually be out of sync with the main branch.
Re:Create React App 4.0 by SahAssar on Sunday October 25, 2020 @08:54AM (#24885934)
That does not mean that it is proprietary, see https://en.wikipedia.org/wiki/Proprietary_software
Re:Create React App 4.0 by cercatrova on Sunday October 25, 2020 @09:18AM (#24886042)
The weird proprietary was used colloquially, not to mean "not open source". In this case, it means something that is only used in relation to one other thing, which is NextJS.
Re:Create React App 4.0 by dbbk on Sunday October 25, 2020 @09:26AM (#24886094)
I obviously did not mean it literally.
Re:Create React App 4.0 by andyfleming on Friday October 23, 2020 @06:29PM (#24874991)
Next.js is more opinionated, has more features, and provides server-side rendering. You might choose one or the other for different use cases.
Re:Create React App 4.0 by loosetypes on Saturday October 24, 2020 @02:18AM (#24877344)
Anyone have recommendations for express api scaffolds in the same vein (and easily compatible with CRA).

I’m looking for something that bakes in background jobs, db structure, and deploy scripts but haven’t found anything with comparable community/usage.

Re:Create React App 4.0 by KarimDaghari on Saturday October 24, 2020 @12:34PM (#24880221)
Maybe take a look at Nest.js: https://nestjs.com/
Re:Create React App 4.0 by sattoshi on Saturday October 24, 2020 @04:14AM (#24877723)
You may like the .NET ecosystem.
Re:Create React App 4.0 by pdxandi on Saturday October 24, 2020 @12:10AM (#24876872)
I know there are tradeoffs to using any project framework or generator, but I'm just impressed by the amount of work people dedicate to these open source platforms. Congratulations on the release! I used this for a production application at work and it's served its purpose masterfully. Thank you for continuing to push the ecosystem forward.