Rendering a component twice

Hi, im rendering the "Wiki" component in root "/".. but I also use it under "/wiki" Is there any way to not "rerender" it and using an unique <Wiki /> call? thanks
22 Replies
Erik
Erikā€¢12mo ago
Can you clarify the question a bit? I am not exactly sure what are you asking.
Kenzo
KenzoOPā€¢12mo ago
Sure, root "/" renders <Wiki /> component - since I want ppl see it when they land on the page wiki "/wiki" route also renders <Wiki /> component -- So wiki unmounts and mounts again, there is any way to persist it? I thought about using it at layout level, but I don't want to render it if i have other routes like "/help"
Erik
Erikā€¢12mo ago
If <Wiki /> is the only component rendered on "/" (so, it's basically a page), I would handle this by adding navigate functionality to "/" which navigates to /wiki. This way anybody who visits "/" will be instantly redirected to "/wiki" and I think this is the right approach because there shouldn't be two different routes giving you exactly the same result. If <Wiki /> is just one of many components rendered on each page, then I think it's not possible to preserve it. Hope this answers your question šŸ™‚
Kenzo
KenzoOPā€¢12mo ago
Thanks šŸ™‚ I was not sure if use redirect since I heard its not recommended to bloat the browsing history of people haha
barry
barryā€¢12mo ago
Overthinking it, just let it render
Kenzo
KenzoOPā€¢12mo ago
NotLikeThisCat I overthink too much
Erik
Erikā€¢12mo ago
That is correct, we shouldn't bloat users' browsing history. However, I think it is ok to use navigate in this case since "/" is literally the root of the app and it's the first thing you visit, so there is nothing to go back to. One thing to keep in mind is if you have any links that should lead to "home" (eg. click on a logo), don't make it lead to "/" so it's being redirected to "/wiki", but rather make it lead directly to "/wiki".
Kenzo
KenzoOPā€¢12mo ago
Oke Ill do that too then šŸ™‚ Btw, do you recommend hosting the pics outside of Vercel? I'm a a bit afraid of the free limit usage since my main bg is 250kb and I'll be having like 20-40 pics, and minimum of 1k views month
Erik
Erikā€¢12mo ago
I haven't dealt with that kind of problem in a while so I really don't know what to say. You will have to ask someone else about that
barry
barryā€¢12mo ago
Cloudinary or making your own CDN with like CloudFlare
Kenzo
KenzoOPā€¢12mo ago
POPOcat
barry
barryā€¢12mo ago
wot
Kenzo
KenzoOPā€¢12mo ago
Vercels 4 types of caching + redis ratelimiting + cdn cloudflare haha Its a bit confusing for me šŸ˜›
barry
barryā€¢12mo ago
in the span of 2 minutes i already did it cloudinary
Kenzo
KenzoOPā€¢12mo ago
oh its easy then šŸ˜„ manual upload + <Image src="https://res.cloudinary.com/-the-real-url" fill alt={name}>.. and thats it? or I'm missing something?
barry
barryā€¢12mo ago
i would use the sdk
Kenzo
KenzoOPā€¢12mo ago
I won't be uploading images from my app
barry
barryā€¢12mo ago
ah then yeah just that
Kenzo
KenzoOPā€¢12mo ago
weird, prettier stopped working when i added const config = { images: { domains: ["localhost", "res.cloudinary.com"], }, }; to next config
Kenzo
KenzoOPā€¢12mo ago
hmm already did that
his file is being treated as an ES module because it has a '.js' file extension and 'c:\Users\xxx\Desktop\toolApp\package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///c:/Users/xxx/Desktop/toolApp/prettier.config.js:5:1
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
his file is being treated as an ES module because it has a '.js' file extension and 'c:\Users\xxx\Desktop\toolApp\package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///c:/Users/xxx/Desktop/toolApp/prettier.config.js:5:1
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
its so weird its asking me for this, its been all day running good Ā“-- fixed it , converted prettier options to .cjs and used use module.exports = config instead of export
Want results from more Discord servers?
Add your server