crux
SWR
crux | SWR | |
---|---|---|
11 | 243 | |
15 | 29,461 | |
- | 0.6% | |
10.0 | 8.2 | |
over 1 year ago | 2 days ago | |
TypeScript | TypeScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
crux
-
How is routing done without React Router
I built a simple router in about 50 lines: https://github.com/andyjessop/crux/blob/main/apps/dev/src/shared/router/router.service.ts
-
Axios reaches 1.0.0
For comparison, I'm writing a front-end framework where the entire size (including router, data fetching/caching, state management) is less than the size of axios.
-
I am sick and tired of react-redux. Who has some good alternatives?
It's like looking in a mirror. This is exactly why I'm working on crux. Seeing as you have similar thoughts, I'd love to hear your feedback.
-
Is redux toolkit essential to project with react or should I be good with basic redux
Immer's a cool library if you don't mind doing this at the top of every reducer: /* eslint-disable no-param-reassign */. I normally prefer some kind of immutable merge function, like this:
-
Hyper Fetch - opinionated fetching framework, async storage with persistance possibilities for both - requests and cache.
Wow, you've done an amazing job there. I prefer your syntax over RTKQuery, and I really like the idea of the queue. I'm implementing a similar kind of thing myself, except just for redux and not as fully-featured as your solution.
-
I built a card game with framer-motion and xstate 👀
Yeah I get this. I would say two things. Firstly, this is aimed primarily at people who are already using Redux. And secondly (and more importantly), Redux itself is not inherently complex - you can write it in 20 lines of code - it's just that the accepted best practices add lots of boilerplate. I've addressed this in my createSlice library, which removes all but the most essential code from the config: https://github.com/andyjessop/crux/tree/main/packages/redux-slice
-
Senior Devs - What are your favorite interview questions for a senior React candidate.
100% agree (both with your opinion and that it's controversial), that's why I'm working on my own framework that attempts to solve this issue: https://github.com/andyjessop/crux
-
What is the most underrated tool you encountered ?
I don't think there's an issue with boilerplate in Redux any more, especially with RTK's prevalence. I made my own createSlice that simplifies the creation of reducers and actions still further - it has an extremely straightforward API and is only 30 or so lines of code.
-
Frameworks
It's not ready for production yet (far from it), but here it is if anyone is interested in finding out more and/or contributing: https://github.com/andyjessop/crux
SWR
-
Best Next.js Libraries and Tools in 2024
Link: https://swr.vercel.app/
-
How to Automatically Consume RESTful APIs in Your Frontend
Now, it's time to consume our API. We'll use React for this tutorail, but feel free to use any other framework you prefer; the process remains the same. Additionally, we'll utilize SWR to fetch data from the API and TypeScript to ensure type safety.
-
A day in the life of a developer - Building a dashboard app with SQL, Node.js, Django and Next.js
'use client'; import FormPostUpdate from './components/FormPostUpdate/FormPostUpdate'; import FormDelete from '../app/components/FormDelete/FormDelete'; import { useFetch } from './hooks/useFetch'; import { useFetchSWR } from './hooks/useFetchSWR'; import Chart from './components/Chart/Chart'; export default function Home() { // Uncomment the code below and comment out the "useFetch" code if your want to use SWR for data fetching --> https://swr.vercel.app/docs/with-nextjs // const { data, error, isLoading } = useFetchSWR( // 'http://127.0.0.1:8000/api/anime/' // ); // Uses the Fetch API for data fetching const { data, error, isLoading } = useFetch( 'http://127.0.0.1:8000/api/anime/' ); if (error) return
An error has occurred.; if (isLoading) returnLoading...; console.log(data); return ( <>POST: Add Anime Form
UPDATE: Update Anime Form
Select an ID from the list. You can change the data for Anime ID, Name and Release.
DELETE: Delete Anime Form
GET: Anime Data List
{data.map((anime) => (-
{anime.anime_name}
- ID: {anime.id}
- Anime ID: {anime.anime_id}
- Anime Release Year: {anime.anime_release}
-
-
API Data Fetching in React / Next.js
There are libraries like SWR, RTK Query, and React Query that simplify the data fetching process on the client and take care of the state, error handling, caching, and re-fetching for you.
-
How to Fetch API Data in React
Then install the package SWR into your application with the following command:
-
45 NPM Packages to Solve 16 React Problems
SWR
-
TanStack Query(a.k.a. React Query) v5 announced
I would suggest taking a look at SWR [0]. I think it strikes a very nice balance between using fetch and something more heavy-handed like React Query.
[0] https://swr.vercel.app/
-
Mastering Data Fetching in React: A Comprehensive Guide to SWR
Check out the official documentation for SWR here
-
Angular vs. React vs. Vue.js: Comparing performance
SWR: A React Hooks library for remote data fetching. It supports features like caching, revalidation, error handling, prefetching, pagination, and support for SSG and SSR. Its bundle size is 10kb minified and 4.4kb gzipped
-
Next.js 13 Data Fetching with App Router
SWR Library
What are some alternatives?
hyper-fetch - ⚡ Fetching and realtime data exchange framework.
axios - Promise based HTTP client for the browser and node.js
signals - Manage state with style in every framework
react-query - 🤖 Powerful asynchronous state management, server-state utilities and data fetching for TS/JS, React, Solid, Svelte and Vue. [Moved to: https://github.com/TanStack/query]
state-machine - A small Javascript Promise-based Finite State Machine implementation
redux - A JS library for predictable global state management
robot - 🤖 A functional, immutable Finite State Machine library
zustand - 🐻 Bear necessities for state management in React
legend-state - Legend-State is a super fast and powerful state library that enables fine-grained reactivity and easy automatic persistence
redux-toolkit - The official, opinionated, batteries-included toolset for efficient Redux development
ky - 🌳 Tiny & elegant JavaScript HTTP client based on the browser Fetch API
redux-saga - An alternative side effect model for Redux apps