Skip to content

Commit a28e5c5

Browse files
author
Bond
committed
Really fix the problem
Render sync if no async component is used
1 parent bd402a8 commit a28e5c5

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

__tests__/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ describe('Components', () => {
147147
expect(testStrategy.mock.calls[0][0].key).toBe(apiKey);
148148
});
149149

150-
test('A span is rendered if image geneation failed', done => {
150+
test('A span is rendered if image generation failed', done => {
151151
const testStrategy = jest.fn(data => Promise.reject('test'));
152152

153153
const wrapper = mount(

src/components/StaticGoogleMap.js

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

129-
if (Array.isArray(childrenUrlParts)) {
129+
/**
130+
* All the parts should return a string if a component that does not return a promise isn't used
131+
* The Directions's component returns a promise and would instead use the Async component to render
132+
* This allows us render sync otherwise and partially support server side rendering.
133+
*/
134+
if (!childrenUrlParts.some(part => typeof part === 'object')) {
130135
const childURL = childrenUrlParts.filter(part => part).join('&');
131136
const url = `${mainUrlParts}&${childURL}`;
132137

0 commit comments

Comments
 (0)