Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

layout.jsx - forces one-time early load of font-awesome css and prevents #156

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Sample-01/app/layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import Footer from '../components/Footer';
import React from 'react';
import { UserProvider } from '@auth0/nextjs-auth0/client';

import '@fortawesome/fontawesome-svg-core/styles.css';

// Force one-time early load of fontawesome and prevent lazy load
// Icons will no longer display large and then re-render to proper size
import { config } from '@fortawesome/fontawesome-svg-core';

config.autoAddCss = false; /* eslint-disable import/first */

export default function RootLayout({ children }) {
return (
<html lang="en">
Expand All @@ -20,6 +28,8 @@ export default function RootLayout({ children }) {
<link rel="stylesheet" href="https://cdn.auth0.com/js/auth0-samples-theme/1.0/css/auth0-theme.min.css" />
</head>
<body>
// Override the RootLayout component to make the authentication
// state available to all pages. Access by using useUser() hook.
<UserProvider>
<main id="app" className="d-flex flex-column h-100" data-testid="layout">
<NavBar />
Expand Down
6 changes: 6 additions & 0 deletions Sample-01/components/Content.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import React from 'react';
import { Row, Col } from 'reactstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { library } from '@fortawesome/fontawesome-svg-core'
import { fas } from '@fortawesome/free-solid-svg-icons'

import contentData from '../utils/contentData';

// Without this, a not-found log to console occurs
library.add(fas);

const Content = () => (

<div className="next-steps my-5" data-testid="content">
<h2 className="my-5 text-center" data-testid="content-title">
What can I do next?
Expand Down