06.
Button
Sungchul Lee
Agenda
Button
In this session, we learn about 1 Button
Button
Add Num 2 Create [Link] with TouchableOpacity
3 [Link] with functions
4 Q&A
Remove Selected item
Add Num
Button
Button
➢A basic button component that should
render nicely on any platform. Supports
a minimal level of customization.
– [Link]
[Link]
➢Create new file
– Generate number
on screen
➢Create <Button>
– title: button display name
➢Props
– Add function from parent
Remove Selected item
Numer List
[Link]
➢Create new file
– Display new numbers
– Delete numbers
➢TouchableOpacity
– Touch event
➢Props
– Delete(idx)
• Pass value to Parent
Map()
➢The map() method creates a new array with the results of
calling a function for every array element.
➢The map() method calls the provided function once for
each element in an array, in order.
➢Note: map() does not execute the function for array
elements without values.
➢Note: this method does not change the original array.
– [Link]
Global_Objects/Array/map
[Link]()
➢[Link]
/Web/JavaScript/Reference/Global_
Objects/Array/map
delete()
➢Props
– Pass Function
– Come from Parent ([Link])
– Pass value index that is selected by onPress
[Link]
[Link]
➢Import components
– generator and numlist
➢State
– random array
• Hold numbers
➢onAddRandomNum
– [Link]()
• rounds a number
– [Link]()
[Link] - function [Link]
avaScript/Reference/Global_Objects/Array/fi
➢onNumDelete(position) lter
– Get argument from numlist
• Position: onPressed item
➢Filter()
– The filter() method creates an array filled with all array
elements that pass a test (provided as a function).
[Link] - Return
➢Pass function
– Generator and NumList components
➢Pass value
– NumList
➢Three Components
➢StyleSheet
Result
Add Num
Remove Sele
cted item
Q&A