React Hooks must be called in the exact same order in every component render. This behavior is even mentioned on Eslint's react-hooks/rules-of-hooks, but is it ok to return null before some hooks render in this following situation?
The Page component receives a prop called keyword, and it's supposed to search for posts based on this keyword. But if the keyword is not defined, we'll not render the page since there's nothing to render to the user.
In this context, is it ok to conditional render before any hooks?
function Search({ keyword }) {
if(typeof keyword == "undefined") return null;
const [searchKeyword, setSearchKeyword] = useState(keyword);
const [searchPosts, setSearchPosts] = useState(await searchPosts(searchKeyword));
}