Skip to content

Commit cbe4dd6

Browse files
committed
install react-snap
1 parent 13fedce commit cbe4dd6

File tree

4 files changed

+434
-45
lines changed

4 files changed

+434
-45
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"deploy": "react-scripts build && cp CNAME build/ && gh-pages -d build",
2626
"eject": "react-scripts eject",
2727
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
28+
"postbuild": "react-snap",
2829
"start": "react-scripts start",
2930
"test": "react-scripts test"
3031
},
@@ -47,5 +48,8 @@
4748
"prettier --write",
4849
"git add"
4950
]
51+
},
52+
"devDependencies": {
53+
"react-snap": "1.23.0"
5054
}
5155
}

src/components/EventCard/index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ export default function EventCard(props) {
3030
overflow="hidden"
3131
shadow="md"
3232
>
33-
<Image
34-
alt={props.name}
35-
src={buildStaticMapUrl(latitude, longitude)}
36-
width="100%"
37-
/>
33+
{process.env.NODE_ENV === 'production' &&
34+
navigator.userAgent !== 'ReactSnap' && (
35+
<Image
36+
alt={props.name}
37+
src={buildStaticMapUrl(latitude, longitude)}
38+
width="100%"
39+
/>
40+
)}
3841
<Flex direction="column" flex={1} p={4}>
3942
<Link href={`https://www.facebook.com/events/${props.id}`}>
4043
<Heading

src/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import './icons';
55
import App from './App';
66
import * as serviceWorker from './serviceWorker';
77

8-
ReactDOM.render(<App />, document.getElementById('root'));
8+
const rootElement = document.getElementById('root');
9+
10+
if (rootElement.hasChildNodes()) {
11+
ReactDOM.hydrate(<App />, rootElement);
12+
} else {
13+
ReactDOM.render(<App />, rootElement);
14+
}
915

1016
// If you want your app to work offline and load faster, you can change
1117
// unregister() to register() below. Note this comes with some pitfalls.

0 commit comments

Comments
 (0)