From 5e7d0ca79cf6decfe8e38fab3625e37219a5bdc9 Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Wed, 1 Aug 2018 23:02:06 +0300 Subject: [PATCH 1/2] Add Intl to off-SPA rendering --- .../SearchMap/ReusableMapContainer.js | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/components/SearchMap/ReusableMapContainer.js b/src/components/SearchMap/ReusableMapContainer.js index d9a4872c..9b5b6663 100644 --- a/src/components/SearchMap/ReusableMapContainer.js +++ b/src/components/SearchMap/ReusableMapContainer.js @@ -1,8 +1,19 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { node, string } from 'prop-types'; +import { IntlProvider } from 'react-intl'; +import mapValues from 'lodash/mapValues'; +import config from '../../config'; +import messages from '../../translations/en.json'; + import css from './SearchMap.css'; +// Locale should not affect the tests. We ensure this by providing +// messages with the key as the value of each message. +const testMessages = mapValues(messages, (val, key) => key); +const isTestEnv = process.env.NODE_ENV === 'test'; +const localeMessages = isTestEnv ? testMessages : messages; + class ReusableMapContainer extends React.Component { constructor(props) { super(props); @@ -42,6 +53,7 @@ class ReusableMapContainer extends React.Component { renderSearchMap() { const targetDomNode = document.getElementById(this.el.id); + let renderContent = this.props.children; // Check if we have already added map somewhere on the DOM if (!targetDomNode) { @@ -51,6 +63,11 @@ class ReusableMapContainer extends React.Component { } else if (!this.mountNode) { // if no mountNode is found, append this outside SPA rendering tree (to document body) document.body.appendChild(this.el); + renderContent = ( + + {this.props.children} + + ); } } else { this.el.classList.remove(css.reusableMapHidden); @@ -62,8 +79,7 @@ class ReusableMapContainer extends React.Component { this.mountNode.appendChild(this.el); } } - - ReactDOM.render(this.props.children, this.el); + ReactDOM.render(renderContent, this.el); } render() { From 2fac1ac84210e7a83ae61f8e11f12fddf8f80988 Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Wed, 1 Aug 2018 23:29:45 +0300 Subject: [PATCH 2/2] Hotfix: update Changelog --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 807b2191..be532614 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ way to update this template, but currently, we follow a pattern: * Patch (v0.0.**X**): Bug fixes and small changes to components. --- +## v1.3.1 +* [fix] Add Intl to off-SPA rendering + [#879](https://github.com/sharetribe/flex-template-web/pull/879) ## v1.3.0 * [change] Reusable SearchMap. diff --git a/package.json b/package.json index c17266df..d6dcbdfd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "app", - "version": "1.3.0", + "version": "1.3.1", "private": true, "license": "Apache-2.0", "dependencies": {