Skip to content

Commit

Permalink
Really fix the problem
Browse files Browse the repository at this point in the history
Render sync if no async component is used
  • Loading branch information
Bond committed Jan 23, 2018
1 parent bd402a8 commit a28e5c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion __tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe('Components', () => {
expect(testStrategy.mock.calls[0][0].key).toBe(apiKey);
});

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

const wrapper = mount(
Expand Down
7 changes: 6 additions & 1 deletion src/components/StaticGoogleMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ class StaticGoogleMap extends Component {
const childrenUrlParts = this.buildParts(children, props) || [];
const mainUrlParts = MapStrategy(props);

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

Expand Down

0 comments on commit a28e5c5

Please sign in to comment.