From 62c1c37a4ce85ef212b950ff3958ef1b9b79a3fa Mon Sep 17 00:00:00 2001 From: wangcheng Date: Wed, 15 Apr 2020 12:22:50 +0800 Subject: [PATCH 1/6] fix: with-mobx --- examples/with-mobx/components/Clock.js | 13 ++++------- examples/with-mobx/components/Page.js | 3 ++- examples/with-mobx/package.json | 8 +++---- examples/with-mobx/pages/_app.js | 32 +++++++++++++++----------- examples/with-mobx/store.js | 22 ++++++++++++++---- 5 files changed, 46 insertions(+), 32 deletions(-) diff --git a/examples/with-mobx/components/Clock.js b/examples/with-mobx/components/Clock.js index c821ed3604ed0..f7c8e322c33ff 100644 --- a/examples/with-mobx/components/Clock.js +++ b/examples/with-mobx/components/Clock.js @@ -1,7 +1,8 @@ -export default props => { +import {observer} from 'mobx-react'; +const Clock = observer(props => { return (
- {format(new Date(props.lastUpdate))} + {props.timeString}
) -} - -const format = t => - `${pad(t.getUTCHours())}:${pad(t.getUTCMinutes())}:${pad(t.getUTCSeconds())}` - -const pad = n => (n < 10 ? `0${n}` : n) +}); +export default Clock; diff --git a/examples/with-mobx/components/Page.js b/examples/with-mobx/components/Page.js index 80b6bd210bc13..4afccd89f46ab 100644 --- a/examples/with-mobx/components/Page.js +++ b/examples/with-mobx/components/Page.js @@ -15,11 +15,12 @@ class Page extends React.Component { } render() { + console.log("render update", this.props.store.timeString); return (

{this.props.title}