Hacker Newsnew | past | comments | ask | show | jobs | submit | dsego's commentslogin

Some people are just too stubborn, especially if they come from a place of authority and seniority. I'm doing house repair work right now with an older relative. He learned how to do repairs and renovations by himself, things like working laminate floors, mortar, laying tiles etc. The things is, he has his own reasoning and rhythym of doing things and doesn't like to be challenged, but I feel his ways don't always make sense, esp when I feel he is rushing and improvising (a programmer can tell). I haven't done much handy work myself in the past, but I'm a millennial, so I google things, watch youtube videos, and I read instructions. I also know that it isn't rocket science, my parents built our own home brick by brick. And now, every step of the way I have to be pushy to get my way, and make it sound like I'm not imposing or too nitpicky or challenging his "expertise", it's very taxing, I made a big scene once already and the whole relationship is now strained.

I was the yielding type, not speaking up, letting others take charge. In my experience, it's not always worth it, especially if you care about the thing you are working on. I went so far as to just dissociate from everything and distance myself from others. The problem is that people deserve your honest opinion if you care about them, even if it's not what they want to hear. But it's so hard to spend mental energy to listen, correct, try to prove your point... even if you succeed, they will resent you for it.

It's not just react query, you can make a quick useFetch and useMutation hooks (or claude can), it's not that complex. If you don't need more advanced features (eg caching), you can easily cut down on 3rd party dependencies.

    import { useState, useEffect } from "react";

    function useFetch(url) {
      const [data, setData] = useState(null);
      const [loading, setLoading] = useState(true);
      const [error, setError] = useState(null);

      useEffect(() => {
        const controller = new AbortController();

        fetch(url, { signal: controller.signal })
          .then((res) => res.json())
          .then((json) => {
            console.log("Data:", json);
            setData(json);
          })
          .catch((err) => {
            if (err.name !== "AbortError") {
              console.error("Fetch error:", err);
              setError(err);
            }
          })
          .finally(() => setLoading(false));

        return () => controller.abort();
      }, [url]);

      return { data, loading, error };
    }







    function App() {
      const { data, loading, error } = useFetch("https://jsonplaceholder.typicode.com/todos/1");

      if (loading) return <p>Loading...</p>;
      if (error) return <p>Error</p>;
      return <pre>{JSON.stringify(data, null, 2)}</pre>;
    }

Sorry for being pedantic, but the first example could be rewritten to extract the pattern into a higher level hook, eg useNotifications. One way to simplify components before reaching for store libraries. The reusable hook now contains all the state and effects and logic, and the component is more tidy.

    function Dashboard() {
      const { user } = useAuth();
      const {loading, error, notifications, undreadCount, markAsRead} = useNotifications(user);

      if (loading) return <Skeleton />;
      if (error) return <p>Failed to load: {error}</p>;

      return (
        <div>
          <h1>Dashboard ({unreadCount} unread)</h1>
          <StatsCards stats={stats} />
          <NotificationList items={notifications} onRead={markAsRead} />
        </div>
      );
    }

Working with multiple teams in a large project, hooks can be a nightmare to maintain.

I see 7x layers deep of hooks, with no test cases to support them. Some of the side effects are not properly tested, and mocks that abstract away the whole implementation means the test case only works for certain scenarios.

FWIW this scenario might be an outlier in large projects, considering how some developers prefer to "just wrap the hook in another hook, and not worry about its internals".


That's a valid concern. I've seen some hard to grok hooks with polling, async stuff, hard to follow logic, etc. Like with anything, need to have taste, it's easy to dump too much into one hook and like you mention, it gets hard to follow what gets triggered when.

I was wondering if I was crazy for thinking "how is what he's suggesting different than just putting that 'class' into a hook function?" I'm glad to see someone already wrote it up, kudos.

@OP: PEBKAC, respectfully.


Far cleaner, how is testability though?

Very easy - mock the useNotifications and you can easily see all the behaviour by changing three properties.

I found this out when I tried running an old app I compiled on MacOS several years ago, it still has the old title bar gradient and traffic light.


It's not just that you need to get used to gestures, it's that they are not discoverable at all, and that they can be awkward to perform with mobility issues, old hands, short fingers, etc. It's easy to make the wrong gesture, eg. the phone detects a swipe down instead of left to right, more so if you are holding it in one hand, so it's finicky and frustrating to have to rely on it as the only way of doing a common action. Why is it so wrong to have a simple navigation bar, it doesn't take up any more space than the hideous notch at the top?


> Surely our camera gear is exponentially better now

They are better, but not exponentially. You can't beat physics, film cameras can still compete in terms of dynamic range and resolution, the optical elements haven't changed that much. The 1972 photo was taken on medium format film, which is twice the size of the sensor area in the modern one, which means more photons and less noise. The recent image was take at a really high ISO, which adds to the noisiness.


I use a Peterson strobe tuner on my smartphone, it's really good. I've also coded my own strobe tuner to learn more, unfortunately no mobile version yet.

https://github.com/dsego/strobe-tuner


Sometimes I want to strike up a conversation but get no reaction or even a dismissive glance and get ignored. It feels like the universe has a script and I went off track.


yes, but is it a good foundation for relationships, after the spell is broken you maybe end up with someone who is not really compatible and the limerant starts resenting their former limerant object.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: