Skip to content

Commit

Permalink
Refactor index.js to extract SetupFontAwesome and SetupFacebookProvid…
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrudny committed Sep 7, 2023
1 parent cfb4dc4 commit b1549c6
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 30 deletions.
40 changes: 10 additions & 30 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,13 @@
import React from 'react';
import { render }from 'react-dom';
import { render } from 'react-dom';
import { Router } from 'react-router-dom';
import * as serviceWorker from './serviceWorker';
import { library } from '@fortawesome/fontawesome-svg-core'
import { FacebookProvider } from 'react-facebook';
import TagManager from 'react-gtm-module'
import TagManager from 'react-gtm-module';
import history from './history';
import App from './App';
import styles from './styles/App.scss';

import {
faInfinity,
faGamepad,
faUser,
faUserSecret,
faUserGraduate,
faUserTie,
faUserNinja,
faCheckSquare,
} from '@fortawesome/free-solid-svg-icons'

library.add(
faInfinity,
faGamepad,
faUser,
faUserSecret,
faUserGraduate,
faUserTie,
faCheckSquare,
faUserNinja
);
import SetupFontAwesome from './utils/setupFontAwesome'; // Updated import path
import SetupFacebookProvider from './utils/setupFacebookProvider'; // New import

const tagManagerArgs = {
gtmId: process.env.REACT_APP_GTM_ID,
Expand All @@ -44,12 +22,14 @@ const rootElement = document.getElementById('root');

render(
<Router history={history}>
<FacebookProvider appId="536292400544593">
<SetupFacebookProvider appId="536292400544593"> {/* Include SetupFacebookProvider */}
<SetupFontAwesome /> {/* Included the SetupFontAwesome component */}
<App />
</FacebookProvider>
</Router>
, rootElement
</SetupFacebookProvider>
</Router>,
rootElement
);

// If you want your common to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: http://bit.ly/CRA-PWA
Expand Down
10 changes: 10 additions & 0 deletions src/utils/setupFacebookProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import { FacebookProvider } from 'react-facebook';

const SetupFacebookProvider = ({ children }) => (
<FacebookProvider appId="536292400544593">
{children}
</FacebookProvider>
);

export default SetupFacebookProvider;
27 changes: 27 additions & 0 deletions src/utils/setupFontAwesome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { library } from '@fortawesome/fontawesome-svg-core';
import {
faInfinity,
faGamepad,
faUser,
faUserSecret,
faUserGraduate,
faUserTie,
faUserNinja,
faCheckSquare,
} from '@fortawesome/free-solid-svg-icons';

const SetupFontAwesome = () => {
library.add(
faInfinity,
faGamepad,
faUser,
faUserSecret,
faUserGraduate,
faUserTie,
faCheckSquare,
faUserNinja
);
return null;
};

export default SetupFontAwesome;

0 comments on commit b1549c6

Please sign in to comment.