weechatRN

Weechat relay client for iOS using websockets https://github.com/mhoran/weechatRN
git clone http://git.hanabi.in/repos/weechatRN.git
Log | Files | Refs | README | LICENSE

commit 61a07e1737134509c6a2e33473b32d8df7c2ea6c
parent 04665e4eb17807332a35591b090edd1b30637330
Author: Matthew Horan <matt@matthoran.com>
Date:   Tue, 22 Jan 2019 22:33:55 -0500

Remove getDerivedStateFromProps from LoginForm

Simply reference props in state initializer.

https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#recommendation-fully-controlled-component

Diffstat:
Msrc/usecase/login/LoginForm.tsx | 22++++------------------
1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/src/usecase/login/LoginForm.tsx b/src/usecase/login/LoginForm.tsx @@ -31,26 +31,12 @@ interface State { class LoginForm extends React.Component<Props, State> { state: State = { - hostname: "", - password: "", - ssl: true, - filterBuffers: true + hostname: this.props.hostname, + password: this.props.password, + ssl: this.props.ssl, + filterBuffers: this.props.filterBuffers }; - static getDerivedStateFromProps(nextProps: Props, prevState: State) { - if (!prevState.hostname && !prevState.password) { - return { - ...prevState, - hostname: nextProps.hostname, - password: nextProps.password, - ssl: nextProps.ssl, - filterBuffers: nextProps.filterBuffers - }; - } else { - return null; - } - } - onPress = () => { this.props.dispatch({ type: "SET_CONNECTION_INFO",