DEV Community

Discussion on: How to Read JSX as "Just Objects"

Collapse
 
dance2die profile image
Sung M. Kim

Thanks Dean for the post and the question.

I prefer the JSX syntax over the method calls (using vdom in your example).

JSX seems to fit better with React eco-system as React tries to be declarative in nature (useEffect is even described as an "escape hatch").

When you deal with declarative code, you delete with "what" not "how"s. It can mean less control over how things work but I think having a readable code can be beneficial in the long run (and dig into imperative implementation details only needed).

From the example in this post.
JSX declares "what" the output look like while vdom shows "how" the element should be rendered.

Just my $0.02.

Collapse
 
deanius profile image
Dean Radcliffe

Hey thanks for the reply, Sung!

I get what you're saying about declarative UI vs imperative. If you find yourself running into edge cases that declarative doesn't handle often enough (and I do!) then I started to wonder if undoing some of those assumptions might help in certain cases.

I think I agree with you that JSX is a good default choice for projects, but if someone has an easier time seeing it from objects, maybe exploring their equivalence may help them.

Collapse
 
dance2die profile image
Sung M. Kim

if someone has an easier time seeing it from objects, maybe exploring their equivalence may help them.

I couldn't agree more as everyone has a different perspective (and background). 🙂