Skip to content

Commit 684d92e

Browse files
committed
switched to functions for hoisting
1 parent aa4717d commit 684d92e

File tree

10 files changed

+45
-28
lines changed

10 files changed

+45
-28
lines changed

.env

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
REACT_APP_DOMAIN=http://localhost
1+
REACT_APP_DOMAIN=http://localhost
2+
REACT_APP_TITLE=React App

src/Apollo.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ const link = new HttpLink({
5656
uri: `${process.env.REACT_APP_DOMAIN}/graphql`,
5757
});
5858

59-
export const ApolloProvider = ({ children }) => {
59+
export function ApolloProvider({ children }) {
6060
const client = new ApolloClient({
6161
link: from([authAfterware, link]),
6262
cache,
6363
});
6464

6565
return <Provider {...{ client }}>{children}</Provider>;
66-
};
66+
}
67+
68+
export default ApolloProvider;

src/App.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Header, Footer, Main } from "./layout";
66
import { Home } from "./home";
77
import "./app.scss";
88

9-
export const App = () => {
9+
export function App() {
1010
const { search } = useLocation();
1111
const previewId = new URLSearchParams(search).get("p");
1212

@@ -25,4 +25,6 @@ export const App = () => {
2525
<Footer />
2626
</div>
2727
);
28-
};
28+
}
29+
30+
export default App;

src/components/ScrollToTop.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { useEffect, useRef } from "react";
22
import { useLocation } from "react-router-dom";
33

4-
const usePrevious = (value) => {
4+
function usePrevious(value) {
55
const ref = useRef();
66
useEffect(() => {
77
ref.current = value;
88
});
99

1010
return ref.current;
11-
};
11+
}
1212

13-
export const ScrollToTop = () => {
13+
export function ScrollToTop() {
1414
const { pathname } = useLocation();
1515
const prevPathname = usePrevious(pathname);
1616

@@ -30,4 +30,6 @@ export const ScrollToTop = () => {
3030
}, [pathname, prevPathname]);
3131

3232
return null;
33-
};
33+
}
34+
35+
export default ScrollToTop;

src/home/Home.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import React from "react";
22
import { PageWidth, PostContent, useNode } from "react-wp-gql";
33

4-
export const Home = () => {
4+
export function Home() {
55
const { node } = useNode();
66

77
return (
88
<PageWidth>
99
<PostContent>{node.content}</PostContent>
1010
</PageWidth>
1111
);
12-
};
12+
}
13+
14+
export default Home;

src/hooks/useSettings.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const SettingsQuery = gql`
99
}
1010
`;
1111

12-
export const useSettings = () => {
12+
export function useSettings() {
1313
const { data, loading, error } = useQuery(SettingsQuery, {
1414
errorPolicy: "all",
1515
});
@@ -21,4 +21,6 @@ export const useSettings = () => {
2121
loading,
2222
error,
2323
};
24-
};
24+
}
25+
26+
export default useSettings;

src/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from "react";
22
import ReactDOM from "react-dom";
3-
import { App } from "./App";
3+
import App from "./App";
44
import { BrowserRouter } from "react-router-dom";
55
import { NodeProvider } from "react-wp-gql";
66
import { ScrollToTop } from "./components";
7-
import { ApolloProvider } from "./Apollo";
7+
import ApolloProvider from "./Apollo";
88
import * as fragments from "./gql/fragments";
99
import reportWebVitals from "./reportWebVitals";
1010

1111
const nodeProps = {
12-
siteName: "React Build",
12+
siteName: process.env.REACT_APP_TITLE,
1313
fragments,
1414
cache: true,
1515
};

src/layout/Footer.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const FooterMenu = gql`
2121
}
2222
`;
2323

24-
const MenuLink = ({ url, label, connectedNode }) => {
24+
function MenuLink({ url, label, connectedNode }) {
2525
let Tag = "a";
2626
const props = { className: "color-inherit no-underline" };
2727
const type = connectedNode?.node?.__typename || "MenuItem";
@@ -34,13 +34,13 @@ const MenuLink = ({ url, label, connectedNode }) => {
3434
}
3535

3636
return <Tag {...props}>{label}</Tag>;
37-
};
37+
}
3838

39-
const FooterColumn = ({ children, className = "" }) => (
40-
<div className={`w-100 w-third-l ${className}`}>{children}</div>
41-
);
39+
function FooterColumn({ children, className = "" }) {
40+
return <div className={`w-100 w-third-l ${className}`}>{children}</div>;
41+
}
4242

43-
export const Footer = () => {
43+
export function Footer() {
4444
const { title, description } = useSettings();
4545
const { data } = useQuery(FooterMenu);
4646
const menu = data?.menuItems?.nodes || [];
@@ -79,4 +79,6 @@ export const Footer = () => {
7979
</div>
8080
</footer>
8181
);
82-
};
82+
}
83+
84+
export default Footer;

src/layout/Header.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState } from "react";
22
import { PageWidth, Menu } from "react-wp-gql";
33
import { Link } from "react-router-dom";
44

5-
export const Header = () => {
5+
export function Header() {
66
const [open, setOpen] = useState();
77

88
return (
@@ -36,4 +36,6 @@ export const Header = () => {
3636
</PageWidth>
3737
</header>
3838
);
39-
};
39+
}
40+
41+
export default Header;

src/layout/Main.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from "react";
22

3-
export const Main = ({ children }) => (
4-
<div className="main lh-copy relative z-1 flex-auto">{children}</div>
5-
);
3+
export function Main({ children }) {
4+
return <div className="main lh-copy relative z-1 flex-auto">{children}</div>;
5+
}
6+
7+
export default Main;

0 commit comments

Comments
 (0)