()
| 72 | this.props.dispatch(actionCreators.getTime(delay)) |
| 73 | } |
| 74 | render () { |
| 75 | |
| 76 | // 因为 Connect 我们能够通过 props 取到特定的数据 |
| 77 | var { frozen, time, reduxState } = this.props |
| 78 | var attrs = {} |
| 79 | const DELAY = 500 // 毫秒 |
| 80 | |
| 81 | if (frozen) { |
| 82 | attrs = { |
| 83 | disabled: true |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | return ( |
| 88 | <div> |
| 89 | <h1>Provider and connect example</h1> |
| 90 | <span> |
| 91 | <b>What time is it?</b> { time ? `It is currently ${time}` : 'No idea yet...' } |
| 92 | </span> |
| 93 | <br /> <br /> |
| 94 | <i> |
| 95 | When clicking the button below, the time will be provided after a {DELAY}ms delay.<br /> |
| 96 | Try to change this value (in <b>src/home.jsx - line 95</b>) to verify that the delay given correctly impacts our UI. |
| 97 | </i> |
| 98 | <br /> |
| 99 | {/* 这里注册按钮的 "onClick" 句柄: */} |
| 100 | <button { ...attrs } onClick={() => this.onTimeButtonClick(DELAY)}>Get time!</button> |
| 101 | <pre> |
| 102 | redux state = { JSON.stringify(reduxState, null, 2) } |
| 103 | </pre> |
| 104 | </div> |
| 105 | ) |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | // 这是我们的 select 函数, 它会把我们需要在属性 (prop) 中对我们的组件暴露的数据从 state 中抽离出来 |
nothing calls this directly
no test coverage detected