我正在做一个React Native项目,尽管我从未使用过React或任何Web或移动开发,但我的经理还是希望我能有所作为。在大多数情况下,它很有趣,并且我能够进行所需的大部分更改,但是,如果有人可以让我更清楚一点,我将努力理解代码的某些部分。我的背景是Java。
在这里我假设handleChange接受一个对象“ updates”而不是状态,但是我对“ changes:{”和那三个点... state.changes,... updates
感到困惑。handleChange = (updates) => {
this.setState((state) => ({
changes: {
...state.changes,...updates,},}))
}
这里我假设mergedUser正在将两个对象“ this.props”和“ this.state”解包到变量中 漩涡状括号,然后返回... userProfile,...更改,再次不确定要使用的点是什么 而且似乎lile userProfile位于screenProps内部的homeStore内部吗?
get mergedUser() {
const {screenProps: {homeStore: {userProfile}}} = this.props
const {changes} = this.state
return {
...userProfile,...changes,}
}
在这里看起来很简单,设置参数TimerId,然后b尝试访问TimerId。但是为什么会有“ routes [0] .routes [0] .routes [0]”为什么不仅this.props.navigation.state.TimerId
a) this.props.navigation.setParams({TimerId})
b) this.props.navigation.state.routes[0].routes[0].routes[0].TimerId
最后一个我不知道发生了什么
export default class LogIn extends Component {
static propTypes = {
navigation: PropTypes.object.isrequired,screenProps: PropTypes.object.isrequired,}
state = {
email: '',}