@@ -45133,27 +45133,6 @@ module.exports = function(originalModule) {
4513345133};
4513445134
4513545135
45136- /***/ }),
45137-
45138- /***/ "./src/components/App.connect.tsx":
45139- /*!****************************************!*\
45140- !*** ./src/components/App.connect.tsx ***!
45141- \****************************************/
45142- /*! no static exports found */
45143- /***/ (function(module, exports, __webpack_require__) {
45144-
45145- "use strict";
45146-
45147- Object.defineProperty(exports, "__esModule", { value: true });
45148- var react_redux_1 = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");
45149- var App_1 = __webpack_require__(/*! ./App */ "./src/components/App.tsx");
45150- var mapStateToProps = function (state) { return ({
45151- loading: !state.map.ready,
45152- }); };
45153- var mapDispatchToProps = function (dispatch, props) { return ({}); };
45154- exports.default = react_redux_1.connect(mapStateToProps, mapDispatchToProps)(App_1.default);
45155-
45156-
4515745136/***/ }),
4515845137
4515945138/***/ "./src/components/App.tsx":
@@ -45165,66 +45144,24 @@ exports.default = react_redux_1.connect(mapStateToProps, mapDispatchToProps)(App
4516545144
4516645145"use strict";
4516745146
45168- var __extends = (this && this.__extends) || (function () {
45169- var extendStatics = function (d, b) {
45170- extendStatics = Object.setPrototypeOf ||
45171- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
45172- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
45173- return extendStatics(d, b);
45174- };
45175- return function (d, b) {
45176- extendStatics(d, b);
45177- function __() { this.constructor = d; }
45178- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
45179- };
45180- })();
4518145147Object.defineProperty(exports, "__esModule", { value: true });
45148+ exports.App = void 0;
4518245149var React = __webpack_require__(/*! react */ "./node_modules/react/index.js");
45183- var Map_connect_1 = __webpack_require__(/*! ./Map.connect */ "./src/components/Map.connect.tsx");
45184- var Weather_connect_1 = __webpack_require__(/*! ./Weather.connect */ "./src/components/Weather.connect.tsx");
45185- var App = /** @class */ (function (_super) {
45186- __extends(App, _super);
45187- function App() {
45188- return _super !== null && _super.apply(this, arguments) || this;
45189- }
45190- App.prototype.render = function () {
45191- return (React.createElement("div", { className: "app" },
45192- this.props.loading && React.createElement("div", { className: "loading" }),
45193- React.createElement("div", { className: "header" },
45194- React.createElement("h1", null, "Weather Map"),
45195- React.createElement("small", null, "(This sample application = React + redux-observable + TypeScript)")),
45196- React.createElement("div", { className: "main" },
45197- React.createElement(Weather_connect_1.default, null),
45198- React.createElement(Map_connect_1.default, null)),
45199- React.createElement("div", { className: "footer" }, "(c) 2018 mitsuru ogawa")));
45200- };
45201- return App;
45202- }(React.Component));
45203- exports.default = App;
45204-
45205-
45206- /***/ }),
45207-
45208- /***/ "./src/components/Map.connect.tsx":
45209- /*!****************************************!*\
45210- !*** ./src/components/Map.connect.tsx ***!
45211- \****************************************/
45212- /*! no static exports found */
45213- /***/ (function(module, exports, __webpack_require__) {
45214-
45215- "use strict";
45216-
45217- Object.defineProperty(exports, "__esModule", { value: true });
45218- var redux_1 = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js");
4521945150var react_redux_1 = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");
45220- var store_1 = __webpack_require__(/*! ../shared/store */ "./src/shared/store/index.ts");
4522145151var Map_1 = __webpack_require__(/*! ./Map */ "./src/components/Map.tsx");
45222- var mapStateToProps = function (state) { return ({}); };
45223- var mapDispatchToProps = function (dispatch, props) { return redux_1.bindActionCreators({
45224- getWeather: function (lat, lng) { return store_1.actions.weatherGetAction(lat, lng); },
45225- mapReady: function () { return store_1.actions.mapReadyAction(); },
45226- }, dispatch); };
45227- exports.default = react_redux_1.connect(mapStateToProps, mapDispatchToProps)(Map_1.default);
45152+ var Weather_1 = __webpack_require__(/*! ./Weather */ "./src/components/Weather.tsx");
45153+ exports.App = function () {
45154+ var ready = react_redux_1.useSelector(function (state) { return state.map; }).ready;
45155+ return (React.createElement("div", { className: "app" },
45156+ !ready && React.createElement("div", { className: "loading" }),
45157+ React.createElement("div", { className: "header" },
45158+ React.createElement("h1", null, "Weather Map"),
45159+ React.createElement("small", null, "(This sample application = React + redux-observable + TypeScript)")),
45160+ React.createElement("div", { className: "main" },
45161+ React.createElement(Weather_1.Weather, null),
45162+ React.createElement(Map_1.Map, null)),
45163+ React.createElement("div", { className: "footer" }, "(c) 2020 mitsuru ogawa")));
45164+ };
4522845165
4522945166
4523045167/***/ }),
@@ -45238,83 +45175,47 @@ exports.default = react_redux_1.connect(mapStateToProps, mapDispatchToProps)(Map
4523845175
4523945176"use strict";
4524045177
45241- var __extends = (this && this.__extends) || (function () {
45242- var extendStatics = function (d, b) {
45243- extendStatics = Object.setPrototypeOf ||
45244- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
45245- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
45246- return extendStatics(d, b);
45247- };
45248- return function (d, b) {
45249- extendStatics(d, b);
45250- function __() { this.constructor = d; }
45251- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
45252- };
45253- })();
4525445178Object.defineProperty(exports, "__esModule", { value: true });
45179+ exports.Map = void 0;
4525545180var React = __webpack_require__(/*! react */ "./node_modules/react/index.js");
45256- var Map = /** @class */ (function (_super) {
45257- __extends(Map, _super);
45258- function Map(props) {
45259- var _this = _super.call(this, props) || this;
45260- _this.onLoaded = _this.onLoaded.bind(_this);
45261- return _this;
45262- }
45263- Map.prototype.componentDidMount = function () {
45264- // remove this key when you run it on your localhost.
45265- var script = document.createElement("script");
45266- script.type = "text/javascript";
45267- script.src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyB5o5wtvz2sf_ckQm9rciFuJxc4pp2Sx-o&callback=initMap";
45268- script.async = true;
45269- document.body.appendChild(script);
45270- window.initMap = this.onLoaded;
45271- };
45272- Map.prototype.render = function () {
45273- return (React.createElement("div", { id: "map" }));
45274- };
45275- Map.prototype.onLoaded = function () {
45276- var _this = this;
45277- this.map = new google.maps.Map(document.getElementById("map"), {
45278- center: { lat: 35.6811673, lng: 139.7648629 },
45279- zoom: 8,
45280- mapTypeControl: false,
45281- disableDoubleClickZoom: false,
45282- fullscreenControl: false,
45283- keyboardShortcuts: false,
45284- streetViewControl: false,
45285- scaleControl: false,
45286- rotateControl: false,
45287- panControl: false,
45288- });
45289- this.map.addListener("click", function (event) {
45290- _this.props.getWeather(event.latLng.lat(), event.latLng.lng());
45291- });
45292- this.props.mapReady();
45293- };
45294- return Map;
45295- }(React.Component));
45296- exports.default = Map;
45297-
45298-
45299- /***/ }),
45300-
45301- /***/ "./src/components/Weather.connect.tsx":
45302- /*!********************************************!*\
45303- !*** ./src/components/Weather.connect.tsx ***!
45304- \********************************************/
45305- /*! no static exports found */
45306- /***/ (function(module, exports, __webpack_require__) {
45307-
45308- "use strict";
45309-
45310- Object.defineProperty(exports, "__esModule", { value: true });
4531145181var react_redux_1 = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");
45312- var Weather_1 = __webpack_require__(/*! ./Weather */ "./src/components/Weather.tsx");
45313- var mapStateToProps = function (state) { return ({
45314- weather: state.weather.weather,
45315- }); };
45316- var mapDispatchToProps = function (dispatch, props) { return ({}); };
45317- exports.default = react_redux_1.connect(mapStateToProps, mapDispatchToProps)(Weather_1.Weather);
45182+ var store_1 = __webpack_require__(/*! ../shared/store */ "./src/shared/store/index.ts");
45183+ exports.Map = function () {
45184+ var dispatch = react_redux_1.useDispatch();
45185+ var mapReady = React.useCallback(function () { return dispatch(store_1.actions.mapReadyAction()); }, [dispatch]);
45186+ var getWeather = React.useCallback(function (lat, lng) { return dispatch(store_1.actions.weatherGetAction(lat, lng)); }, [dispatch]);
45187+ var mapRef = React.useCallback(function (node) {
45188+ if (node !== null) {
45189+ var onLoaded = function () {
45190+ var map = new google.maps.Map(node, {
45191+ center: { lat: 35.6811673, lng: 139.7648629 },
45192+ zoom: 8,
45193+ mapTypeControl: false,
45194+ disableDoubleClickZoom: false,
45195+ fullscreenControl: false,
45196+ keyboardShortcuts: false,
45197+ streetViewControl: false,
45198+ scaleControl: false,
45199+ rotateControl: false,
45200+ panControl: false,
45201+ });
45202+ map.addListener("click", function (e) {
45203+ getWeather(e.latLng.lat(), e.latLng.lng());
45204+ });
45205+ mapReady();
45206+ };
45207+ // remove this key when you run it on your localhost.
45208+ var script = document.createElement("script");
45209+ script.type = "text/javascript";
45210+ script.src =
45211+ "https://maps.googleapis.com/maps/api/js?key=AIzaSyB5o5wtvz2sf_ckQm9rciFuJxc4pp2Sx-o&callback=initMap";
45212+ script.async = true;
45213+ document.body.appendChild(script);
45214+ window.initMap = onLoaded;
45215+ }
45216+ }, []);
45217+ return React.createElement("div", { id: "map", ref: mapRef });
45218+ };
4531845219
4531945220
4532045221/***/ }),
@@ -45331,8 +45232,9 @@ exports.default = react_redux_1.connect(mapStateToProps, mapDispatchToProps)(Wea
4533145232Object.defineProperty(exports, "__esModule", { value: true });
4533245233exports.Weather = void 0;
4533345234var React = __webpack_require__(/*! react */ "./node_modules/react/index.js");
45334- exports.Weather = function (_a) {
45335- var weather = _a.weather;
45235+ var react_redux_1 = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");
45236+ exports.Weather = function () {
45237+ var weather = react_redux_1.useSelector(function (state) { return state.weather; }).weather;
4533645238 if (!weather) {
4533745239 return null;
4533845240 }
@@ -45370,13 +45272,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
4537045272var React = __webpack_require__(/*! react */ "./node_modules/react/index.js");
4537145273var ReactDOM = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js");
4537245274var react_redux_1 = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");
45373- var App_connect_1 = __webpack_require__(/*! ./components/App.connect */ "./src/components/App.connect .tsx");
45275+ var App_1 = __webpack_require__(/*! ./components/App */ "./src/components/App.tsx");
4537445276/**
4537545277 * Redux store setup
4537645278 */
4537745279var store_1 = __webpack_require__(/*! ./shared/store */ "./src/shared/store/index.ts");
4537845280ReactDOM.render(React.createElement(react_redux_1.Provider, { store: store_1.store },
45379- React.createElement(App_connect_1.default , null)), document.getElementById("root"));
45281+ React.createElement(App_1.App , null)), document.getElementById("root"));
4538045282
4538145283
4538245284/***/ }),
0 commit comments