News for hackers. Stuff that matters.
Re:RFC: Intent to Ship React 18 by Spivak on Thursday March 24, 2022 @05:01PM (#30795287)
And you can put hooks in if statements too, but like iterables it won't have the effect you probably want.

    it = ["hello", "world", "foo", "bar"]

    shouldbehello = next(it)
    shouldbeworld = next(it)

    if sometimes_true_sometimes_false:
       shouldbefoo = next(it)

    # if the conditional is false this will be foo, oops.
    shouldbebar = next(it)
Hooks aren't callback functions, they're functions that take callback functions. apparently this is breaking python. The naming convention is just so the linter can identify hooks, they're not magic.

    def react_to_stuff(func, var):
       orig = var.copy()

       def monitor():
          while True:
              sleep 2
              if var != orig:
                  orig = var.copy()
                  func(var)

       t = Thread(target=monitor)
       t.start()

     stuff = "Hello"
     react_to_stuff(lambda x: print(x), stuff)
Re:RFC: Intent to Ship React 18 by dmitriid on Friday March 25, 2022 @03:33AM (#30799546)
No idea why you're giving examples in Python code when we're talking about Javascript and React.

On "it's iterators actually", I have a response to a sibling comment here: https://news.ycombinator.com/item?id=30799543

Re:RFC: Intent to Ship React 18 by Spivak on Friday March 25, 2022 @08:49AM (#30801512)
Because it’s better pseduocode and the concept isn’t language dependent.