4 ms·
Red Flags in a React Codebase
- ttfkam 3y agoLet's examine these limitations in the context of Svelte/SvelteKit: • functions named handleClick,handleSubmit Agreed, not as descriptive as it could be, but when your component is noticeably smaller, arguably not as big a deal. • preventDefault React tries control the execution model to the point that plain JS ends up in an impedance mismatch. Go ahead in Svelte since it embraces JS. Or you can use on:click|preventDefault={doIt} • useMemo N/A. This is an abstraction leak solely of React's making. Not needed at all in other frameworks like Svelte. • fetch inside useEffect A special wrapper library to use the Fetch API in React? Sure, you could use a wrapper in Svelte as well, but it's not necessary. • <div onClick/> Universally good advice no matter your framework. Use button or a tag. • a "hooks" directory Here's where a framework being more opinionated helps. Technically it doesn't matter where the hook logic lives, but having the framework make that decision means you don't have to, and others don't have to hunt around as much to find it. • css files Svelte scopes CSS to the component by default. No arm-twisting or custom build logic needed. • icon library in package.json Your tree-shaking tools work or they don't.