Replace componentWillMount with componentDidMount and as required, construct(). Fixes #179
This commit is contained in:
parent
7e1457bb8d
commit
24b72b5828
29 changed files with 47 additions and 54 deletions
|
@ -20,7 +20,7 @@ class AboutPage extends ImmutablePureComponent {
|
|||
});
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
this.loadPageHtml();
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class Header extends ImmutablePureComponent {
|
|||
return !location.pathname.match(/\/(followers|following|favorites|pins)\/?$/);
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
window.addEventListener('resize', this.handleResize, { passive: true });
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class AccountTimeline extends ImmutablePureComponent {
|
|||
unavailable: PropTypes.bool,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
const { params: { username }, accountId, withReplies, me } = this.props;
|
||||
|
||||
if (accountId && accountId !== -1) {
|
||||
|
|
|
@ -61,7 +61,7 @@ class CaptchaField extends React.Component {
|
|||
});
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
this.fetchCaptcha();
|
||||
this.startRefresh(); // Refresh periodically
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class Blocks extends ImmutablePureComponent {
|
|||
intl: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
this.props.dispatch(fetchBlocks());
|
||||
}
|
||||
|
||||
|
|
|
@ -168,6 +168,18 @@ class PrivacyDropdown extends React.PureComponent {
|
|||
placement: 'bottom',
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const { intl: { formatMessage } } = this.props;
|
||||
|
||||
this.options = [
|
||||
{ icon: 'globe', value: 'public', text: formatMessage(messages.public_short), meta: formatMessage(messages.public_long) },
|
||||
{ icon: 'unlock', value: 'unlisted', text: formatMessage(messages.unlisted_short), meta: formatMessage(messages.unlisted_long) },
|
||||
{ icon: 'lock', value: 'private', text: formatMessage(messages.private_short), meta: formatMessage(messages.private_long) },
|
||||
{ icon: 'envelope', value: 'direct', text: formatMessage(messages.direct_short), meta: formatMessage(messages.direct_long) },
|
||||
];
|
||||
}
|
||||
|
||||
handleToggle = ({ target }) => {
|
||||
if (this.props.isUserTouching()) {
|
||||
if (this.state.open) {
|
||||
|
@ -210,17 +222,6 @@ class PrivacyDropdown extends React.PureComponent {
|
|||
this.props.onChange(value);
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
const { intl: { formatMessage } } = this.props;
|
||||
|
||||
this.options = [
|
||||
{ icon: 'globe', value: 'public', text: formatMessage(messages.public_short), meta: formatMessage(messages.public_long) },
|
||||
{ icon: 'unlock', value: 'unlisted', text: formatMessage(messages.unlisted_short), meta: formatMessage(messages.unlisted_long) },
|
||||
{ icon: 'lock', value: 'private', text: formatMessage(messages.private_short), meta: formatMessage(messages.private_long) },
|
||||
{ icon: 'envelope', value: 'direct', text: formatMessage(messages.direct_short), meta: formatMessage(messages.direct_long) },
|
||||
];
|
||||
}
|
||||
|
||||
render() {
|
||||
const { value, intl } = this.props;
|
||||
const { open, placement } = this.state;
|
||||
|
|
|
@ -33,7 +33,7 @@ class Blocks extends ImmutablePureComponent {
|
|||
intl: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
this.props.dispatch(fetchDomainBlocks());
|
||||
}
|
||||
|
||||
|
|
|
@ -117,18 +117,15 @@ class EditProfile extends ImmutablePureComponent {
|
|||
event.preventDefault();
|
||||
}
|
||||
|
||||
setInitialState = () => {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const initialState = this.props.account.withMutations(map => {
|
||||
map.merge(map.get('source'));
|
||||
map.delete('source');
|
||||
map.set('fields', normalizeFields(map.get('fields')));
|
||||
unescapeParams(map, ['display_name', 'note']);
|
||||
});
|
||||
this.setState(initialState.toObject());
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.setInitialState();
|
||||
this.state = initialState.toObject();
|
||||
}
|
||||
|
||||
handleCheckboxChange = e => {
|
||||
|
|
|
@ -34,7 +34,7 @@ class Favourites extends ImmutablePureComponent {
|
|||
isMyAccount: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
this.props.dispatch(fetchFavouritedStatuses());
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class Favourites extends ImmutablePureComponent {
|
|||
accountIds: ImmutablePropTypes.list,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
this.props.dispatch(fetchFavourites(this.props.params.statusId));
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class Filters extends ImmutablePureComponent {
|
|||
intl: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
this.props.dispatch(fetchFilters());
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class FollowRequests extends ImmutablePureComponent {
|
|||
intl: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
this.props.dispatch(fetchFollowRequests());
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class Followers extends ImmutablePureComponent {
|
|||
unavailable: PropTypes.bool,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
const { params: { username }, accountId } = this.props;
|
||||
|
||||
if (accountId && accountId !== -1) {
|
||||
|
|
|
@ -58,7 +58,7 @@ class Following extends ImmutablePureComponent {
|
|||
diffCount: PropTypes.number,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
const { params: { username }, accountId } = this.props;
|
||||
|
||||
if (accountId && accountId !== -1) {
|
||||
|
|
|
@ -49,7 +49,8 @@ class Create extends React.PureComponent {
|
|||
onCoverImageChange: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.props.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,8 @@ class Edit extends React.PureComponent {
|
|||
setUp: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
componentWillMount(nextProps) {
|
||||
constructor(nextProps) {
|
||||
super(nextProps);
|
||||
if (this.props.group) {
|
||||
this.props.setUp(this.props.group);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class Groups extends ImmutablePureComponent {
|
|||
intl: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
this.props.dispatch(fetchGroups(this.props.activeTab));
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class GroupMembers extends ImmutablePureComponent {
|
|||
hasMore: PropTypes.bool,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
const { params: { id } } = this.props;
|
||||
|
||||
this.props.dispatch(fetchMembers(id));
|
||||
|
|
|
@ -37,7 +37,7 @@ class GroupRemovedAccounts extends ImmutablePureComponent {
|
|||
hasMore: PropTypes.bool,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
const { params: { id } } = this.props;
|
||||
|
||||
this.props.dispatch(fetchRemovedAccounts(id));
|
||||
|
|
|
@ -84,7 +84,8 @@ class Introduction extends React.PureComponent {
|
|||
currentIndex: 0,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.pages = [
|
||||
<FrameWelcome domain={this.props.domain} onNext={this.handleNext} />,
|
||||
<FrameFederation onNext={this.handleNext} />,
|
||||
|
|
|
@ -42,7 +42,7 @@ class Lists extends ImmutablePureComponent {
|
|||
intl: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
this.props.dispatch(fetchLists());
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class Mutes extends ImmutablePureComponent {
|
|||
intl: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
this.props.dispatch(fetchMutes());
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class PinnedStatuses extends ImmutablePureComponent {
|
|||
isMyAccount: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
this.props.dispatch(fetchPinnedStatuses());
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class Reblogs extends ImmutablePureComponent {
|
|||
status: ImmutablePropTypes.map,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
this.props.dispatch(fetchReblogs(this.props.params.statusId));
|
||||
this.props.dispatch(fetchStatus(this.props.params.statusId));
|
||||
}
|
||||
|
|
|
@ -139,11 +139,8 @@ class Status extends ImmutablePureComponent {
|
|||
loadedStatusId: undefined,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
this.props.dispatch(fetchStatus(this.props.params.statusId));
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.dispatch(fetchStatus(this.props.params.statusId));
|
||||
attachFullscreenListener(this.onFullScreenChange);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class Bundle extends React.PureComponent {
|
|||
forceRender: false,
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
this.load(this.props);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class FocalPointModal extends ImmutablePureComponent {
|
|||
dragging: false,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
this.updatePositionFromMedia(this.props.media);
|
||||
}
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ class SwitchingColumnsArea extends React.PureComponent {
|
|||
mobile: isMobile(window.innerWidth),
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
window.addEventListener('resize', this.handleResize, { passive: true });
|
||||
}
|
||||
|
||||
|
@ -394,9 +394,9 @@ class UI extends React.PureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
const { me } = this.props;
|
||||
if (!me) return;
|
||||
window.addEventListener('beforeunload', this.handleBeforeUnload, false);
|
||||
|
||||
document.addEventListener('dragenter', this.handleDragEnter, false);
|
||||
|
@ -420,11 +420,6 @@ class UI extends React.PureComponent {
|
|||
|
||||
setTimeout(() => this.props.dispatch(fetchFilters()), 500);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { me } = this.props;
|
||||
if (!me) return;
|
||||
this.connectStreaming();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class GroupPage extends ImmutablePureComponent {
|
|||
dispatch: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
componentDidMount() {
|
||||
const { params: { id }, dispatch } = this.props;
|
||||
|
||||
dispatch(fetchGroup(id));
|
||||
|
|
Loading…
Reference in a new issue