Skip to content

Commit a233262

Browse files
Stop mutating date in createDateObjects method
The original method reset the `date` to `startOf('month')` and this can be very confusing. It gave me a headache this afternoon fixing a state issue
1 parent d625a47 commit a233262

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/createDateObjects.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import moment from 'moment';
22

33
export default function createDateObjects(date, weekOffset = 0) {
4-
const startOfMonth = date.startOf('month');
4+
const startOfMonth = moment(date).startOf('month');
55

66
let diff = startOfMonth.weekday() - weekOffset;
77
if (diff < 0) diff += 7;

0 commit comments

Comments
 (0)