24 Aralık 2020 Perşembe


 import React, { useState } from 'react'

import { ViewTextButton } from 'react-native'

const randomDiceRoll = () => Math.floor(Math.random() * 6) + 1

export default function App() {
  const [diceRolls, setDiceRolls] = useState([])

  return (
    <View>
      <Button
        title="Roll dice!"
        onPress={() => {
          setDiceRolls(() => [...diceRolls, randomDiceRoll()])
        }}
      />
        <Text>
          {diceRolls}
        </Text>
      {diceRolls.map((diceRoll, index) => (
        <Text style={{ fontSize: 24 }} key={index}>
          {diceRoll}
        </Text>
      ))}
    </View>
  )
}

Hiç yorum yok:

Yorum Gönder