In my build I have two files with the same code: gatsby-browser.js and gatsby-ssr.js. The code is pretty simple, it uses wrapPageElement to wrap pages in a <Layout /> component:
// gatsby-browser.js gatsby-ssr.js
import React from 'react';
import Layout from './src/components/Layout';
export function wrapPageElement({ element, props }) {
return <Layout {...props}>{element}</Layout>;
}
I'd like to hand this code off to one file and then import it into both documents, thereby giving it the DRY treatment, but I'm a bit unsure on the best way of doing this. Can anyone suggest a best practice here?