Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 28469

spinet of React native code and few questions regarding State and Props

$
0
0

I am working on a React Native project that my manager wants me to teak a little bit even though I never worked with react or any web or mobile development. for the most part it's Been fun and I was able to make most of the changes needed, however I am struggling to understand some parts of the code if anyone can make thing a little bit clearer to me. My background is Java.

here I assume handleChange takes an object "updates" than update the state but I am confused of what "changes: {" is and those three dots ...state.changes, ...updates,

handleChange = (updates) => {
    this.setState((state) => ({
      changes: {
        ...state.changes,
        ...updates,
      },
    }))
  }

here I assume mergedUser is unpacking two objects "this.props" and "this.state" to the variables swirly brackets then returning ...userProfile, ...changes, again not sure what's the dots for and also it seems lile userProfile was inside homeStore that was inside screenProps?

get mergedUser() {
    const {screenProps: {homeStore: {userProfile}}} = this.props
    const {changes} = this.state

    return {
      ...userProfile,
      ...changes,
    }
  }

here it looks easy, a set the param TimerId and b try to access TimerId. but why there is "routes[0].routes[0].routes[0]" why not only this.props.navigation.state.TimerId

  a) this.props.navigation.setParams({TimerId})
  b) this.props.navigation.state.routes[0].routes[0].routes[0].TimerId

Lastly this one I have no idea of what's going on on it

export default class LogIn extends Component {
  static propTypes = {
    navigation: PropTypes.object.isRequired,
    screenProps: PropTypes.object.isRequired,
  }
  state = {
    email: '',
  }

Viewing all articles
Browse latest Browse all 28469

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>