←back to thread

174 points tipiirai | 2 comments | | HN request time: 0s | source
Show context
Kaotique ◴[] No.42736637[source]
It is interesting, but I really dislike the way it tries to bash every other tech in the blog post, on the homepage and in the docs itself. The tone is very confident, but it will put you open to a lot of scrutiny.

Instead it could really use a lot more explanation on how it works. If you make comparisons make sure they are fair. The image "JavaScript mixed together" and "Strict separation of concerns" is just comparing apples with oranges. Multiple times in the docs it compares a huge complicated JSX like component and replaces it with 3 lines of html and 3 lines of css. I don't believe that it does the same thing.

Some of the claims are strange. It praises standard HTML but apparently you have to use some custom Markdown syntax to write it. How does that add up? And on top of that it also introduces new syntax for loops and variables.

This could all work perfectly fine. But my suggestion would be to talk more about how it works and what are the advantages and less trying to bring down competitors. It could use less grand claims and focus more on what it really does.

replies(5): >>42737254 #>>42737462 #>>42737988 #>>42738672 #>>42754583 #
lelanthran ◴[] No.42737254[source]
> Multiple times in the docs it compares a huge complicated JSX like component and replaces it with 3 lines of html and 3 lines of css.

I've seen my fair share of React code, and the code he is displaying is definitely idiomatic React.

> It could use less grand claims and focus more on what it really does.

Agreed. While I appreciate that a rationale is needed for something like this, I think his presentation of the rationale was far too verbose compared to diving into some code.

Maybe I'm not the target - I would have preferred more code and less pontificating, because I 'noped right out of React and others. What I have as a replacement in standard JS, HTML and CSS is unsatisfying to me.

replies(1): >>42740621 #
robertoandred ◴[] No.42740621[source]
> the code he is displaying is definitely idiomatic React

It's really not. There's nothing, for example, stopping you from using <dialog> in React. It works perfectly fine and can integrate with any state or event manager if you want it to.

What he's doing is comparing brand-new web features that don't have good support yet with long-standing solutions that were needed years before those web features were a glimmer in anyone's eye.

replies(1): >>42741443 #
lelanthran ◴[] No.42741443[source]
>> the code he is displaying is definitely idiomatic React

> It's really not.

Of the React projects I've seen (including a ton on github), none of them used the browsers dialog without a React wrapper.

A quick search on google for a React project using `<dialog>` found none. Similar for github.

If you have an example, I'd like to see a link, because I'm skeptical that React projects are using `<dialog>` without wrapping it in React.

replies(3): >>42741617 #>>42741692 #>>42745262 #
robertoandred ◴[] No.42741617{3}[source]
I'm not sure what you're searching for or what you consider "wrapping it in React". You need some sort of JS to open and close it.

const Modal = ({ isOpen, onRequestClose, ...rest }: ComponentProps<"dialog"> & { isOpen: boolean; onRequestClose: () => unknown; }) => {

  const dialogRef = useRef<HTMLDialogElement>(null);

  useLayoutEffect(() => {
    if (isOpen) {
      dialogRef.current?.showModal();
    } else {
      dialogRef.current?.close();
    }
  }, [isOpen]);

  return (
    <dialog
      ref={dialogRef}
      onClose={(e) => {
        e.preventDefault();
        onRequestClose();
      }}
      {...rest}
    />
  );
};
replies(1): >>42764999 #
spartanatreyu ◴[] No.42764999{4}[source]
I didn't need any JS here:

  <dialog open>
    <p>Greetings, one and all!</p>
    <form method="dialog">
      <button>OK</button>
    </form>
  </dialog>
replies(1): >>42765273 #
1. robertoandred ◴[] No.42765273{5}[source]
And if you don’t want it open when you load the page?
replies(1): >>42774943 #
2. spartanatreyu ◴[] No.42774943[source]
get rid of the open attribute