Skip to content

Commit 1cca1fe

Browse files
committed
Fixed due to comment in pr
1 parent fcdd450 commit 1cca1fe

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

dist/react-pure-time.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/example.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/react-pure-time.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ const Time = (props: Props) => {
138138
});
139139

140140
React.useEffect(() => {
141+
console.log("rerender", state);
142+
141143
let interval: null | number = null;
142144
if (props.relativeTime && isDate(props.value)) {
143145
const date = new Date(props.value);
@@ -154,10 +156,9 @@ const Time = (props: Props) => {
154156
interval = window.setInterval(() => {
155157
const date = new Date(props.value);
156158
setState({
157-
...state,
158159
currentUnit: props.unit || bestFit(diff),
160+
relativeTime: updateRelativeTime(date, props.unit || bestFit(diff)),
159161
});
160-
updateRelativeTime(date, state.currentUnit);
161162
}, getInterval(state.currentUnit));
162163
}
163164

0 commit comments

Comments
 (0)