Workaround for RN 0.54 on iOS (#246)

This commit is contained in:
Diego Mello 2018-03-06 14:40:44 -03:00 committed by GitHub
parent 872532251b
commit fcf55d259f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 34 deletions

View File

@ -17,6 +17,7 @@ export default class Fade extends React.Component {
this.state = { this.state = {
visible: props.visible visible: props.visible
}; };
this._visibility = new Animated.Value(this.props.visible ? 1 : 0);
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
@ -32,10 +33,6 @@ export default class Fade extends React.Component {
}); });
} }
UNSAFE_componentWillMount() {
this._visibility = new Animated.Value(this.props.visible ? 1 : 0);
}
render() { render() {
const { style, children, ...rest } = this.props; const { style, children, ...rest } = this.props;

View File

@ -36,17 +36,13 @@ export default class EmojiCategory extends React.Component {
const { width, height } = this.props.window; const { width, height } = this.props.window;
this.size = Math.min(this.props.width || width, height) / (this.props.emojisPerRow || emojisPerRow); this.size = Math.min(this.props.width || width, height) / (this.props.emojisPerRow || emojisPerRow);
this.emojis = []; this.emojis = props.emojis;
} }
shouldComponentUpdate() { shouldComponentUpdate() {
return false; return false;
} }
UNSAFE_componentWillMount() {
this.emojis = this.props.emojis;
}
renderItem(emoji, size) { renderItem(emoji, size) {
return ( return (
<TouchableOpacity <TouchableOpacity

View File

@ -42,6 +42,10 @@ export default class EmojiPicker extends Component {
componentDidMount() { componentDidMount() {
requestAnimationFrame(() => this.setState({ show: true })); requestAnimationFrame(() => this.setState({ show: true }));
this.frequentlyUsed.addListener(this.updateFrequentlyUsed);
this.customEmojis.addListener(this.updateCustomEmojis);
this.updateFrequentlyUsed();
this.updateCustomEmojis();
} }
componentWillUnmount() { componentWillUnmount() {
this.frequentlyUsed.removeAllListeners(); this.frequentlyUsed.removeAllListeners();
@ -64,13 +68,6 @@ export default class EmojiPicker extends Component {
} }
} }
UNSAFE_componentWillMount() {
this.frequentlyUsed.addListener(this.updateFrequentlyUsed);
this.customEmojis.addListener(this.updateCustomEmojis);
this.updateFrequentlyUsed();
this.updateCustomEmojis();
}
_addFrequentlyUsed = (emoji) => { _addFrequentlyUsed = (emoji) => {
database.write(() => { database.write(() => {
database.create('frequentlyUsedEmoji', emoji, true); database.create('frequentlyUsedEmoji', emoji, true);

View File

@ -52,6 +52,16 @@ export default class Sidebar extends Component {
gotoAddServer: PropTypes.func.isRequired gotoAddServer: PropTypes.func.isRequired
} }
constructor(props) {
super(props);
this.state = { servers: [] };
}
componentDidMount() {
database.databases.serversDB.addListener('change', this.updateState);
this.setState(this.getState());
}
componentWillUnmount() { componentWillUnmount() {
database.databases.serversDB.removeListener('change', this.updateState); database.databases.serversDB.removeListener('change', this.updateState);
} }
@ -72,11 +82,6 @@ export default class Sidebar extends Component {
servers: database.databases.serversDB.objects('servers') servers: database.databases.serversDB.objects('servers')
}) })
UNSAFE_componentWillMount() {
database.databases.serversDB.addListener('change', this.updateState);
this.setState(this.getState());
}
updateState = () => { updateState = () => {
this.setState(this.getState()); this.setState(this.getState());
} }

View File

@ -88,6 +88,12 @@ export default class ListServerView extends React.Component {
this.data.addListener(this.updateState); this.data.addListener(this.updateState);
} }
componentDidMount() {
zeroconf.on('update', this.updateState);
zeroconf.scan('http', 'tcp', 'local.');
this.setState(this.getState());
}
componentDidUpdate() { componentDidUpdate() {
if (this.props.connected && if (this.props.connected &&
this.props.server && this.props.server &&
@ -140,14 +146,6 @@ export default class ListServerView extends React.Component {
}; };
}; };
UNSAFE_componentWillMount() {
zeroconf.on('update', this.updateState);
zeroconf.scan('http', 'tcp', 'local.');
this.setState(this.getState());
}
updateState = () => { updateState = () => {
this.setState(this.getState()); this.setState(this.getState());
} }

View File

@ -70,6 +70,10 @@ export default class LoginView extends React.Component {
this.redirectRegex = new RegExp(`(?=.*(${ this.props.server }))(?=.*(credentialToken))(?=.*(credentialSecret))`, 'g'); this.redirectRegex = new RegExp(`(?=.*(${ this.props.server }))(?=.*(credentialToken))(?=.*(credentialSecret))`, 'g');
} }
componentDidMount() {
this.props.open();
}
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
if (this.props.services !== nextProps.services) { if (this.props.services !== nextProps.services) {
LayoutAnimation.easeInEaseOut(); LayoutAnimation.easeInEaseOut();
@ -150,10 +154,6 @@ export default class LoginView extends React.Component {
return Base64.encodeURI(JSON.stringify({ loginStyle: 'popup', credentialToken, isCordova: true })); return Base64.encodeURI(JSON.stringify({ loginStyle: 'popup', credentialToken, isCordova: true }));
} }
UNSAFE_componentWillMount() {
this.props.open();
}
openOAuth = (oAuthUrl) => { openOAuth = (oAuthUrl) => {
this.setState({ oAuthUrl, modalVisible: true }); this.setState({ oAuthUrl, modalVisible: true });
} }

View File

@ -57,7 +57,7 @@ export default class MentionedMessagesView extends React.PureComponent {
}; };
} }
componentWillMount() { componentDidMount() {
this.props.navigation.setParams({ this.props.navigation.setParams({
onPressToogleStatus: this.onPressToogleStatus, onPressToogleStatus: this.onPressToogleStatus,
allUsers: this.state.allUsers allUsers: this.state.allUsers