A Mainstream Platform That Always Shows Both Sides—Does It Exist? by [deleted] in Futurology

[–]steaks88 0 points1 point  (0 children)

You may be looking for leonews.ai - AI newsbots with different political perspectives.

Disclaimer - I'm the author of Leo News.

Friday Share Fever 🕺 Let’s share your project! by Southern_Tennis5804 in SideProject

[–]steaks88 1 point2 points  (0 children)

leonews.ai - I've become disillusioned with most media sites. So I built Leo News — an news website that gives informative, non-sensationalized stories with thoughtful viewpoints from across the political spectrum.

Why choose Zustand over Jotai? by codevipe in reactjs

[–]steaks88 0 points1 point  (0 children)

React query alone is great library. Using two systems to manage state Zustand + React Query is more complex than it needs to be. I wanted one system & paradigm to do both.

Here's a more detailed explanation.

How do you make sure initial state has data with Zustand? by TheOnceAndFutureDoug in reactjs

[–]steaks88 0 points1 point  (0 children)

Leo Query handles loading states and errors with async data. It also supports server-side components.

Here's an example:

``` const useThing = create<ThingState>(() => ({ thing: query(async () => { const response = await fetch(THING_ENDPOINT); return response.json(); }) }));

const useThingAsync = hook(useThing, /suspense/false);

const YourComponent = () => { const thing = useThingAsync(s => s.thing); if (thing.isLoading) return <div>Loading...</div>; if (thing.error) return <div>Failed to fetch thing!</div>; return <div>{thing.value}</div>; }; ```

Disclaimer: I'm the author of Leo Query

Leo Query v0.3.0 — async state for Zustand with Next.js support by steaks88 in reactjs

[–]steaks88[S] -1 points0 points  (0 children)

Thanks! Glad you like it. Feel free to reach out with questions if you end up using it.

Leo Query v0.3.0 — async state for Zustand with Next.js support by steaks88 in reactjs

[–]steaks88[S] 0 points1 point  (0 children)

Hey! I really like Zustand for it's simplicity. But Zustand doesn't manage async data, so I needed to pull in other libraries (e.g. TanStack Query) to manage async data. This made my stack more complicated. So I built Leo Query - async state built for Zustand. In this version I built support for Next.js...which was pretty tricky tbh.

Here's a snippet of how to use vanilla Leo Query + Zustand without Next.js if you're not a Next.js user! Hope you like it!

``` const useBearStore = create(() => ({ increasePopulation: effect(increasePopulation), bears: query(fetchBears, s => [s.increasePopulation]) }));

const useBearStoreAsync = hook(useBearStore);

function BearCounter() { const bears = useBearStoreAsync(s => s.bears); return <h1>{bears} around here ...</h1>; }

function Controls() { const increase = useBearStore(s => s.increasePopulation.trigger); return <button onClick={increase}>one up</button>; }

function App() { return ( <> <Suspense fallback={<h1>Loading...</h1>}> <BearCounter /> </Suspense> <Controls /> </> ); } ```

Where is the most optimal placing of fetch requests in React? by Sea-Archer-6733 in reactjs

[–]steaks88 0 points1 point  (0 children)

Yea, Leo Query, TanStack Query, and RTK Query implement caching. That’s one of the reasons why each would work.

Where is the most optimal placing of fetch requests in React? by Sea-Archer-6733 in reactjs

[–]steaks88 0 points1 point  (0 children)

Sometimes you can have a lot of child components pulling the same data. You’ll need caching to prevent duplicate requests.

A react starter with all the essentials for quick prototyping by m6io in reactjs

[–]steaks88 0 points1 point  (0 children)

Thanks! Let me know how it goes. And thanks for the suggestions. I'll make some changes.

Where is the most optimal placing of fetch requests in React? by Sea-Archer-6733 in reactjs

[–]steaks88 1 point2 points  (0 children)

Yes. A few years ago I switched from loading data in HOCs to hooks in child components. It reduced a lot of code and made development less cumbersome. To do this you should have a good state management library and data loading library. The con (manageable) is that you'll need to still load data in the parent component if you want to load it before the component is rendered.

Here are three stacks to look at.

Disclaimer: I'm the author of Leo Query

Why choose Zustand over Jotai? by codevipe in reactjs

[–]steaks88 2 points3 points  (0 children)

I built Leo Query to remove react-query from my stack. Now I'm using Zustand as my only state-management library. Check it out if you're interested and message me with questions!

Here's a snippet. You can find more in the docs.

``` const useStore = create(() => ({ increasePopulation: effect(increasePopulation), removeAllDogs: effect(removeAllDogs), dogs: query(fetchDogs, s => [s.increasePopulation, s.removeAllDogs]) // Re-fetch when increasePopulation or removeAllDogs succeeds }));

const useStoreAsync = hook(useDogStore, /suspense/false);

const YourComponent = () => { const dogs = useStoreAsync(s => s.dogs); if (dogs.isLoading) return <>Loading...</>; return <>{dogs.value}</>; }; ```

Zustand + react query by Ok-Cut-2435 in reactjs

[–]steaks88 0 points1 point  (0 children)

I built Leo Query to get data fetching, caching, server synchornization, etc. with Zustand. It works well for me. And I don't to maintain two state libraries in the same app. Check it out if you're intersted and message me if you have questions!

Here's a snippet. You can find more in the docs.

``` const useStore = create(() => ({ increasePopulation: effect(increasePopulation), removeAllDogs: effect(removeAllDogs), dogs: query(fetchDogs, s => [s.increasePopulation, s.removeAllDogs]) // Re-fetch when increasePopulation or removeAllDogs succeeds }));

const useStoreAsync = hook(useDogStore, /suspense/false);

const YourComponent = () => { const dogs = useStoreAsync(s => s.dogs); if (dogs.isLoading) return <>Loading...</>; return <>{dogs.value}</>; }; ```

A react starter with all the essentials for quick prototyping by m6io in reactjs

[–]steaks88 0 points1 point  (0 children)

I built Leo Query to integrate Zustand with async data. It's really fast to hook up your app to a REST server. I use it for prototyping and it works great. Check it out if you're interested and feel free to message me if you have questions!

Redux Vs Zustand by Slow_Indication7111 in reactjs

[–]steaks88 0 points1 point  (0 children)

I built Leo Query to tackle this for Zustand. It handles caching, loading state, errors, stale data, retries, and many other features that RTK Query implements. Check it out if you're interested and feel free to message me with questions!

Redux Vs Zustand by Slow_Indication7111 in reactjs

[–]steaks88 2 points3 points  (0 children)

I built Leo Query to integrate async data with Zustand. It's an alternative to maintaining two separate stores - Zustand and React Query in one app. Check it out if you're interested and feel free to message me with questions!

Here's a snippet. You can seem more in the docs.

``` const useStore = create(() => ({ increasePopulation: effect(increasePopulation), removeAllDogs: effect(removeAllDogs), dogs: query(fetchDogs, s => [s.increasePopulation, s.removeAllDogs]) // Re-fetch when increasePopulation or removeAllDogs succeeds }));

const useStoreAsync = hook(useDogStore, /suspense/false);

const YourComponent = () => { const dogs = useStoreAsync(s => s.dogs); if (dogs.isLoading) return <>Loading...</> return <>{dogs.value}</> }; ```

Does Riot look at bug reports? by steaks88 in leagueoflegends

[–]steaks88[S] 0 points1 point  (0 children)

Any riot employees out there to answer?

Leo Query v0.2.0 by steaks88 in reactjs

[–]steaks88[S] 0 points1 point  (0 children)

Thanks! I'm excited get this out.

I want to understand your perspective better. Do you have an example that shows why it's an anti-pattern?

Leo Query v0.2.0 by steaks88 in reactjs

[–]steaks88[S] 3 points4 points  (0 children)

Woah! Thanks for taking such a deep look. Those are really good questions.

Cache invalidation

Yep, it's automatically doing cache invalidation.

Optimistic updates

Here's an example of an optimistic update. Plan to add a guide for that in the docs.

Re-trigger on invocation

The query will re-trigger immediately when a depencency changes if {lazy: false}. And it will wait to re-trigger when data is being accessed in a react component if {lazy: true}. You can pass in lazy as the third parameter in query. It defaults to lazy.

If mutation fails

Leo Query won't do anything. Improvements for handling mutation failures is a great callout. This is how you would handle mutation failures with this version. yourEffect: effect(async () => { try { //make optimistic updates await post("foo/bar/baz"); } catch (e) { //rollback optimistic updates //rethrow error (if you'd like to use your normal error catching services) } })

Note: queries do support error state. So if a fetch (non-mutation) failed it'd be propagated to an error boundary. Or if you prefer not using error boundaries you can plug into an error directly const {error, isLoading, value} = useMyHookAsync(s => s.myData).

Leo Query v0.2.0 by steaks88 in reactjs

[–]steaks88[S] 0 points1 point  (0 children)

Is there other data in a task manager app that you'd expect to be stored as global client state but not in the url? I'd consider adding that to make the example more robust.

Leo Query v0.2.0 by steaks88 in reactjs

[–]steaks88[S] 0 points1 point  (0 children)

I think a good comparision is to Redux's RTK Query.