Archive for March 2024
React theme brakepoints
xs: Extra small devices (less than 600px) sm: Small devices (600px and up) md: Medium devices (900px and up) lg: Large devices (1200px and up) xl: Extra large devices (1536px and up) <Box sx={(theme) => ({ textAlign: ‘center’, [theme.breakpoints.up(’md’)]: { textAlign: ‘left’ }, })} > TEXT </Box> theme.breakpoints.up(‘md’) means @media (min-width: 900px) So, the above […]
Javascript match prefix
const hostname = "www.someaddress.com" console.log(!!hostname.startsWith(’www.’) ? ‘matching’ : ‘not matching’)
Next.js usePathname(), useParams(), useSearchParams() in new App Router
‘use client’ import {usePathname, useParams, useSearchParams} from "next/navigation"; // folder structure: app/team/[teamName]/page.tsx // url: http://localhost:3002/team/something?query=mine /* Expected output: Pathname: /team/something Params: something SearchParams: mine */ export default function Page() { let queryResult: string | null | undefined = null // params dataset placeholder let params: Record<string, string | string[]> | null […]