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

Updating an object attribute Typescript React-Native

$
0
0

I'm trying to update an attribute. I'm new to typescipt (and react/react-native/javascript etc.) so please be patient. Here is an attempt to try to recreate my issue:

export default function App() {  const [schedule, setSchedule] = useState({    id: 12409,    name: 'Schedule1',    start: 9,    end: 10  })  const [startHour, setStartHour] = useState({    start: 7  })  const [endHour, setEndHour] = useState({    end: 11  })  const [scheduleFinal, setFinal] = useState(schedule)  submitPress(() => {      setFinal([...schedule], start, start: startHour.start)    };    return ( <      View ><      Button title = "Change Start and End"      onPress = {        submitPress      }      /> <      Text > New start: {        scheduleFinal.start      }      New End: {        scheduleFinal.end      } < /Text> <      /View>    );  }

I am trying to replace the attributes:

startend

in the schedule object with the attributes held in startHour and endHour states. I've tried various combinations of logic that haven't worked. I'm not sure if the method that I have here will work at all, but at least people should be able to tell what I am after.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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