Hydrate should be wrapped around every page on our website and can be adjusted for simple static pages, interactive dynamic pages and everything in between.
The following example doesn't do much, but it's the starting point from which features can be enabled.
import hydrate from '@dpdk/library/utilities/hydrate';
function Home() {
return <h1>Welcome to your page</h1>;
}
export default hydrate(Home);
The hydrate function in this case did a few things:
/en/home
for example)The next step is adding sections, this is not required, but allows individual sections later on to have their own data queries.
import hydrate from '@dpdk/library/utilities/hydrate';
function HeroSection(){
return <h1>Hero!</h1>;
}
function ImageSection(){
return <Image />;
}
// children in props are the specified sections
function Home({ children }) {
return (
<>
<Menu />
{children}
<Footer />
</>
);
}
export default hydrate(Home, [HeroSection, ImageSection]);
Last modified | Monday, August 30, 2021, 2:00:02 PM UTC |
Last author | Colin van Eenige |
Commit ID | fd08685 |