Skip to content

Commit 0a075cf

Browse files
author
Bond
committed
Support partial server side rendering
If the Directions component isn't used which returns a promise, allow the url to be generated synchronously to allow for server side rendering in most cases.
1 parent 66057cf commit 0a075cf

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/components/StaticGoogleMap.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ class StaticGoogleMap extends Component {
126126
const childrenUrlParts = this.buildParts(children, props) || [];
127127
const mainUrlParts = MapStrategy(props);
128128

129+
if (Array.isArray(childrenUrlParts)) {
130+
const childURL = childrenUrlParts.filter(part => part).join('&');
131+
const url = `${mainUrlParts}&${childURL}`;
132+
133+
if (onGenerate) {
134+
onGenerate(url);
135+
}
136+
137+
return <Component {...componentProps} src={url} />;
138+
}
139+
129140
const urlParts = Promise.all(childrenUrlParts).then(
130141
parts => `${mainUrlParts}&${parts.filter(part => part).join('&')}`
131142
);

0 commit comments

Comments
 (0)