Skip to content
Advertisement

Best practice for Next.js data fetching inside a component

I have a menu component that appears globally. What is the best practice for getting data into that component? I’m trying to take advantage of static generation that Next.js offers but all data fetching guidance from the Next.js team relates to pages. getStaticProps and getStaticPaths seem to pertain to page generation, not data for components. Is their SWR package the

window.getSelection().baseOffset is wrong

If you select any text below beginning at the first character H, it will say the baseOffset of the selection is 5. In my real-life case it says 7. How do I correct this? Answer The result is correct, you have exactly 5 space characters between the end of <div id=’main’data-alignment=”center”> and the H, these will be counted as offset.

reactjs setstate not working in function that has .map

Good Morning. Need help, i have the below script, the thing is the setState is not working, I think I’m missing something here? or Am i doing wrong. the “return” in the below is inside “.map” so i could display the 3 file in the array. Thanks Answer I imagine you want to recreate the file array, just changing the

Advertisement