Skip to content

Instantly share code, notes, and snippets.

View shameemreza's full-sized avatar
🇧🇩
Problem-Solver | WooCommerce Expert | Customer-First Mindset

Shameem Reza shameemreza

🇧🇩
Problem-Solver | WooCommerce Expert | Customer-First Mindset
View GitHub Profile
@shameemreza
shameemreza / equality.js
Created January 20, 2023 12:05
Strict and Loose Equality Example in JavaScript
// Use strict equality when comparing variables of the same type
let age = 25;
let legalAge = 21;
console.log(age === legalAge); // false
// Use loose equality when comparing variables that may be a string or a number
let input = "25";
let number = 25;
console.log(input == number); // true
@shameemreza
shameemreza / ssrpost1.js
Created January 27, 2023 05:05
Example for Mastering the Art of Server-Side Rendering with Next.js
import React from 'react'
const About = () => {
return (
<div>
<h1>About Our App</h1>
<p>Our app is the best thing since sliced bread.</p>
</div>
)
}
@shameemreza
shameemreza / ssrpost2.js
Created January 27, 2023 05:06
Example of Mastering the Art of Server-Side Rendering with Next.js
import Link from 'next/link'
const Home = () => {
return (
<div>
<Link href="/about">
<a>About</a>
</Link>
</div>
)
@shameemreza
shameemreza / ssrpost3.js
Last active January 27, 2023 05:11
Example of Mastering the Art of Server-Side Rendering with Next.js
import axios from 'axios'
const About = ({ data }) => {
return (
<div>
<h1>About Our App</h1>
<p>Our app is the best thing since sliced bread.</p>
<p>Data from API: {data}</p>
</div>
)
function UserProfile({ user }) {
return (
<div>
<h1>{user.name}</h1>
<p>{user.bio}</p>
</div>
);
}
export async function getServerSideProps(context) {
import { useRouter } from "next/router";
function UserProfile() {
const router = useRouter();
const { id } = router.query;
// Fetch data for user with id
...
return (
function UserProfile({ user }) {
return (
<div>
<h1>{user.name}</h1>
<p>{user.bio}</p>
</div>
);
}
export async function getServerSideProps(context) {
@shameemreza
shameemreza / create-react-component.js
Created March 31, 2023 17:06
Code for the "How to Render an Array of Objects in React?" Article.
import React from "react";
function EmployeeList() {
return (
<div>
{/* Render the employee list here */}
</div>
);
}
@shameemreza
shameemreza / mp-through-array-of-objects.js
Created March 31, 2023 17:08
Code for the "How to Render an Array of Objects in React?" Article.
import React from "react";
function EmployeeList() {
const employees = [
{ name: "John Doe", age: 25, position: "Software Engineer" },
{ name: "Jane Smith", age: 32, position: "Product Manager" },
{ name: "Mike Johnson", age: 27, position: "UI/UX Designer" },
{ name: "Sarah Lee", age: 30, position: "Marketing Manager" },
];