This project is my REACTION to the video β¬οΈ
Not entirely correct
π€ Instead of editing in Mongo Atlas, we can use CMS for marketing team can edit too.
npm create-next-app -e with-tailwindcss my-project
-
π Folder pages where all pages in your site placed
-
π TailwindCSS allows you quickly applying CSS to components
- Font
- Text size
- Color
-
Nextjs
- Replace class component by function component
function Search() { return ( <div> Search <div/> ) } export default Search
-
Path
- Ex: localhost:3000/NFT/para-farm
- Create folder NFT under pages folder then
[id].tsx
this mean wildcard
-
Flexbox
<div className="flex h-screen flex-col lg:grid lg:grid-cols-10"> {/* Left */} <div className="lg:col-span-4"> <div> LEFT </div> </div> </div>
lg:min-h-screen
meaning on large screen the min height of component is the height of the screenlg:h-96 lg:w-72
meaning on large screen (height, width) = (96, 72)<button className="px-4 py-2 lg:px-5 lg:py3"/>
meaning ONLY (5,3) in large screen, OTHER screens (small, medium) will be (4,2). Same apply forflex
(small, medium) large will go withgrid
flex-1 flex-col
1 meaning get all the spaceIf not large screen case, it will back to 'flex' mode, meaning it will layout at it's ease
β οΈ Flex it NOT Grid- Flex: 1 dimensional layout, will expand all items in 1 line then go to next line.
Flex everything is on the same row - Grid: 2 dimensionals
Split the screen by cols
https://www.geeksforgeeks.org/comparison-between-css-grid-css-flexbox/
Fine to use both at the same component which means depends on - Flex: 1 dimensional layout, will expand all items in 1 line then go to next line.
// by row, but each row will divide by number of cols <flex> <grid /> <flex/> // or // by number of cols, but each col will layout in one row <grid> <flex /> <grid/>
-
Thirdweb: Wrap your entire app (_app.tsx)
return( <ThirdwebProvider desiredChainId={ChainId.bsc}> <Component {...pageProps} /> </ThirdwebProvider> )
π Beside that, thirdweb provides NFT drop, which you can just upload the images and hit Deploy button Instead of
1.png
and1.json
we can use bulk upload replace json files by .csv -
π Vercel:
https://vercel.com/
You can deploy your FE for free, connecting thru github -
π² Opensea test net
https://testnets.opensea.io/ -
π΄ Typescript
We need define the type to avoid warning// typings.d.ts where you specify how object should look interface Image { asset: { url: string } } export interface Creator { _id: string name: string image: Image bio: string } export interface Collection { _id: string title: string creator: Creator address: string } // index.js interface Props { collections: Collection[] }
Typescript using interface to define type
-
πΈπΈπΈ Fetch
-
In
Next.js
usinggetServerSideProps
to fetch data everytime it renders the pageYou should use getServerSideProps only if you need to render a page whose data must be fetched at request time https://nextjs.org/docs/pages/building-your-application/data-fetching/get-server-side-props
-
Next.js is server render/ pre-rendering
Actually, bothReact
andNext.js
are hosted in Remote server so both are SSR (server side rendering) BUT react render page by download js files instead html tags likeNext.js
so Next is lil better
-
SSR | CSR |
---|---|
![]() |
![]() |
https://www.freecodecamp.org/news/next-vs-react/
https://blog.logrocket.com/create-react-app-vs-next-js-performance-differences/
-
πΈ Router
<Link href={/nft/collection.slug.current}> <div> </Link>
param?.id
for getting params in urlhttps://nextjs.org/docs/pages/building-your-application/routing/linking-and-navigating
-
πΈ useEffect
without
conditions
it will run every time it's render
function NFTDropPage({collection}: Props) {
const [claimedSupply, setClaimedSupply] = useState<number>(0)
const nftDrop = useNFTDrop(collection.address)
//π€ CAN use many useEffect as you want
useEffect(()=> {
//fetchPrice
}, [])
useEffect(()=> {
if (!nftDrop) return; //defensive programming
const fetchNFTDropData = async () => {
const claimed = await nftDrop.getAllClaimed();
setClaimedSupply(claimed.length)
}
fetchNFTDropData()
},[nftDrop])
}
I see no reason to use Sanity as content center (CMS). π€·ββοΈ- Surprisingly, this entire app despite strongly is a Another blockchain tutorial, but not a single line of Sol written. thirdweb is all you need π€
- Using testnet open-sea to check minting instead bsc-scan π
This repo was developed by @lamha. Follow or connect with me on my LinkedIn.