When I write this code, I expect my React Component to display nothing. However, it displays '0'. Why is this?
import React from "react";
import ReactDOM from "react-dom";
const App = () => {
const object = {
array: []
}
return (
<>
{object.array && object.array.length && (
<p>Test</p>
)}
</>
);
}
ReactDOM.render(<App />, document.getElementById("root"));
See this code sandbox for a live demo: https://codesandbox.io/s/sad-lovelace-mmrkz