by tiborsaas · 5y ago · 0 comments
function Component({ children }) {
const { data, loading, error } = useGetMyData();
return (
<>
{loading && <div>Loading...</div>}
{error && <div className="red">{error.message}</div>}
{!loading && !error && <>
<div>Data:</div>
<div className="green">{data}</div>
{children}
</>}
</>
);
}
> However, HTML is too declarative of an S-expression to be efficient in constructing the DOM.This is statement is also stinking. HTML is meant to describe the DOM and does a great job at it.
On another note, I'd suggest ternaries with explicit null returns. Just need to get burned by it once to have it engrained! https://kentcdodds.com/blog/use-ternaries-rather-than-and-an...
What ifs are what ifs ;)
Fair point on the ternaries, I use that too when it makes sense.