React Native Guess A Number

React Native Guess A Number

rn-Guess-A-Number This project was created with React Native

React-Native/React Snippets

  • irmc - import for React
  • irnc - import for React-Native
  • rncslwc - complete react-native skeleton
  • rnss - stylesheet section

View

  • Operates just like a div in React.js
  • Has a built-in flexbox with a default of flex-direction: column

Shadow Properties

  • Only works on IOS. To fix this, we add an elevation property.

Card.js File

"props.children"

  • Special prop in React which is basically the content you pass between the opening and closing tags.

Example:

        <View>
            <Text>Select A Number</Text>
            <TextInput />
            <View style={styles.buttonContainer}>
                <Button title='Reset' onPress={() => {}} />
                <Button  title='Confirm' onPress={() => {}} /> 
            </View>
        </View>
All the content between the parent View tag are the 'children'

-So therefore if we import the Card.js component into whatever file we need it to be in, we can wrap the content (children) with the Card component like so:
     <Card>
        <Text>Select A Number</Text>
         <TextInput />
         <View style={styles.buttonContainer}>
            Button title='Reset' onPress={() => {}} />
            Button  title='Confirm' onPress={() => {}} /> 
        </View>
    </Card>

"<View style={{...styles.card, ...props.style}}>"

  • What this code does is it makes the code more flexible and reusable. The spread operator uses all the styles properties but the props.style piece enables you to overwrite the measurements.

For example:

    In the stylesheet you have
        alignItems: 'center',
        shadowColor: 'black'

    The props.style with the spread operator will enable you to change the measurements like so:
        alignItems: 'stretch',
        shadowColor: 'grey'

Input.js

  • '...props' enable us to add any other props we want (as long as it is compatible) to the component when customizing it in another component.

StartGameScreen.js

const numberInputHandler = inputText => {
        setEnteredValue(inputText.replace(/[^0-9]/g, ''));
};
  • This statement says that globally, any entered value, that is NOT a number will be replaced with an empty string.

  • On an IOS device, the keypad will only show numbers, however, on an android the keypad shows numbers, a comma, and a period. Therefore this logic is necessary.

TouchableWithoutFeedback - This enables the user to click in other places on the screen and close the keypad without any feedback from the screen.

Keyboard.dismiss() - Once the user clicks on the screen, the keyboard disappears.

parseInt() - A function that converts its first argument to a string, parses that string, then returns an integer or NaN .

App.js

In the following statement, the StartGameScreen component was stored in a variable in order to write a conditional that says that if the user picks a number (the userNumber) then the variable (content) will switch over to the GameScreen.

let content = <StartGameScreen />

  if (userNumber) {
    content = <GameScreen />
  }

GameScreen.js

Download Details:

Author: Code4Blessings

Source Code: https://github.com/Code4Blessings/rn-Guess-A-Number

react-native react mobile-apps

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

React Native App Developers India, React Native App Development Company

Hire React Native app developers India from a preferred React Native app development company by innovative industry leaders. Let's Discuss Your Project.

React Native Mobile App Development

Skenix is providing React Native Development Services with qualified React Native App Developers. Get the best React Native App Development Services.

How React Native Is Shaping Mobile App Development

Are you a mobile app developer looking for more efficient tools for your projects? Mobile app development is getting tougher and tougher as the market continues to grow. As a developer, you need to develop Apps which meet the demands of your users. To achieve this, adopt the right tools, like the React Native development framework.

Top React Native Mobile App Development Companies in USA

Looking for top React Native mobile app development company in USA for Startups & Enterprise? Find out the top list of React Native mobile app development company in USA.