Skip to content

Commit

Permalink
chore: add optional chaining for collections (#66)
Browse files Browse the repository at this point in the history
Co-authored-by: Onur <[email protected]>
  • Loading branch information
resatyavcin and suyalcinkaya authored Feb 18, 2024
1 parent d5a674b commit 7c2ab8f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/bookmarks/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default async function BookmarksLayout({ children }) {
<SideMenu title="Bookmarks" href="/bookmarks" isInner>
<Suspense fallback={<LoadingSpinner />}>
<div className="flex flex-col gap-1 text-sm">
{collections.map((collection) => {
{collections?.map((collection) => {
return (
<ListItem
key={collection._id}
Expand Down
2 changes: 1 addition & 1 deletion src/app/bookmarks/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default async function Writing() {
<ScrollArea className="flex flex-col lg:hidden">
<FloatingHeader title="Bookmarks" />
<div>
{collections.map((collection) => {
{collections?.map((collection) => {
return (
<Link
key={collection._id}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const isDevelopment = process.env.NODE_ENV === 'development'
* @returns The sorted array in ascending order based on the specified property.
*/
export const sortByProperty = (arr, prop) => {
return arr.sort((a, b) => {
return arr?.sort((a, b) => {
const itemA = a[prop].toUpperCase()
const itemB = b[prop].toUpperCase()

Expand Down

0 comments on commit 7c2ab8f

Please sign in to comment.