Here the 30 lines of code in Vanilla JavaScript can be replaced by just 10 lines of React code, see the difference;

React:-

< ol >
< li > List item 1 < /li >
< li > List item 2 (child list)
< ul >
< li > Subitem 1 < /li >
< li > Subitem 2 < /li >
< /ul >
< /li >
< li > Final list item < /li >
< /ol >

Equivalent Vanilla JavaScript:-

React.createElement(
“ol”,
null,
React.createElement(
“li”,
null,
“List item 1 ”
),
React.createElement(
“li”,
null,
“List item 2 (child list)”,
React.createElement(
“ul”,
null,
React.createElement(
“li”,
null,
“Subitem 1”
),
React.createElement(
“li”,
null,
“Subitem 2”
)
)
),
React.createElement(
“li”,
null,
“Final list item”
)
);

Leave a Reply

Your email address will not be published. Required fields are marked *