I am here with a basic question. If I directly compare variables then I can get defined results. But I can not check if a passed value as property is null or undefined. Because it is showing never as null or undefined. So conditional checking not working. So please advice me, how to check if a property is undefined or null.
import { memo, useRef } from "react";
const MyComponent = (myList) => {
const renderTimes = useRef(0);
return (
<div>
{renderTimes.current++}
<div>Rendered : {renderTimes.current} times.</div>
{console.log(
"block. Is it null? : ",
myList === null,
" is it undefined ? ",
myList === undefined,
"Check type:",
typeof myList === "undefined"
)}
</div>
);
};
export default MyComponent;
<MyComponent myList={undefined} />
If I pass nothing or even I passed named property as null and undefined both the time it shows same result.

({ myList })or useprops.myListnullorundefined, in this case it is the props object.({myList}), it still shows as not null, but it shows as undefined. even if I pass<MyComponent myList={null}>.{myList: undefined}, it's not equalnullorundefined