Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(component): fixing unsafe_method in daycolumn.js #2441

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions src/DayColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ class DayColumn extends React.Component {
state = { selecting: false, timeIndicatorPosition: null }
intervalTriggered = false

static getDerivedStateFromProps(nextProps, prevState) {
if (nextProps.selectable && !prevState?.selectable) {
if (this && this._selectable) {
this._selectable()
}
}

if (!nextProps.selectable && prevState?.selectable) {
this._teardownSelectable()
}

const updatedSlotMetrics = prevState?.slotMetrics?.update(nextProps)

return {
selectable: nextProps.selectable,
slotMetrics: updatedSlotMetrics,
}
}

constructor(...args) {
super(...args)

Expand All @@ -38,14 +57,6 @@ class DayColumn extends React.Component {
this.clearTimeIndicatorInterval()
}

UNSAFE_componentWillReceiveProps(nextProps) {
if (nextProps.selectable && !this.props.selectable) this._selectable()
if (!nextProps.selectable && this.props.selectable)
this._teardownSelectable()

this.slotMetrics = this.slotMetrics.update(nextProps)
}

componentDidUpdate(prevProps, prevState) {
const { getNow, isNow, localizer, date, min, max } = this.props
const getNowChanged = localizer.neq(prevProps.getNow(), getNow(), 'minutes')
Expand Down