JavaScript React native - add currency prefix to TextInput react native currency input,react native currency format,react native

How can add a currency prefix to a TextInput in React Native? Here is an example of what I'm trying to achieve: enter image description here

To give a bit more details - the TextInput should have a default value, for instance £10. I would like the currency sign to always be there. At some point this value will be sent to a database so it should be converted to an integer.

My code so far (_renderSecondTile section):

import React, {Component} from 'react'
import {
    Text,
    View,
    ListView,
    ScrollView,
    StyleSheet,
    Image,
    TouchableHighlight,
    TextInput,
} from 'react-native'


class AppView extends Component {
    state = {
        isPlayerOneButtonActive: false,
        isPlayerTwoButtonActive: false,
        isThirdTileActive: false,
        textInputValue: '£10',
    }

     activateButton = buttonToActivate => {
        const newState = Object.assign(
            {},
            {
                isPlayerOneButtonActive: false,
                isPlayerTwoButtonActive: false,
            },
            {[buttonToActivate]: true},
        )
        this.setState(newState);
    }

    showThirdTile = tileToShow => {
        this.setState({isThirdTileActive: tileToShow});
    }

    _renderSecondTile = () => {
         if(this.state.isPlayerOneButtonActive || this.state.isPlayerTwoButtonActive) {
             return(
                 <TouchableHighlight>
                     <View style={[styles.step, styles.stepTwo]}>
                        <View style={{flex: 1}}>
                             <Text style={styles.heading}>Enter amount</Text>
                             <View style={styles.amountInputContainer}>
                                 <TextInput
                                     onKeyPress={() => {this.showThirdTile(true)}}
                                     style={styles.amountInput}
                                     maxLength = {3}
                                     value={this.state.textInputValue}
                                 />
                             </View>
                         </View>
                     </View>
                 </TouchableHighlight>
             )
         }
         else{
             return null;
         }
    }

    _renderThirdTile = () => {
        if(this.state.isSecondTitleActive){
            return(
                <View style={[styles.step, styles.stepThree]}>
                    <View style={{flex:1}}>
                        <Text style={styles.heading}>Third tile</Text>
                    </View>
                </View>
            )
        }
        else{
            return null;
        }
    }

    render(){
        const {isPlayerOneButtonActive} = this.state

        return (
            <ScrollView style={styles.container}>
                <View style={[styles.step, styles.stepOne]}>
                    <View style={{flex:1}}>
                        <Text style={styles.heading}>Pick player</Text>
                        <View style={styles.pickContainer}>
                            <TouchableHighlight onPress={() => {this.activateButton('isPlayerOneButtonActive')}}>
                                <Text>Player One</Text>
                            </TouchableHighlight>

                            <TouchableHighlight onPress={() => {this.activateButton('isPlayerTwoButtonActive')}}>
                                <Text>Player One</Text>
                            </TouchableHighlight>
                        </View>
                    </View>
                </View>

                {this._renderSecondTile()}

                {this._renderThirdTile()}
            </ScrollView>
        )
    }
}
Answer:1

I'm working on an electron app(first time using electron). I'm also very new to javascript so please excuse my stupidity. In the index.js file I have this method to check if a network connection ...

I'm working on an electron app(first time using electron). I'm also very new to javascript so please excuse my stupidity. In the index.js file I have this method to check if a network connection ...

I have created a custom matcher in jasmine to verify if an element has a class or not. This is the code that I have placed in the beforeEach() function to define the custom matcher: beforeEach(...

I have created a custom matcher in jasmine to verify if an element has a class or not. This is the code that I have placed in the beforeEach() function to define the custom matcher: beforeEach(...

I'm trying to make an advanced <select> tag but implementing an input before the first <option> attribute for searching. Something like this: Here is my code. How can I add <input name=...

I'm trying to make an advanced <select> tag but implementing an input before the first <option> attribute for searching. Something like this: Here is my code. How can I add <input name=...

I'm using angularjs for my application and found this issue on google chrome, the problem is I have this URL: http://127.0.0.1/#/fa/episode/1315019/برنامه-خوب but when I click on this links it shows:...

I'm using angularjs for my application and found this issue on google chrome, the problem is I have this URL: http://127.0.0.1/#/fa/episode/1315019/برنامه-خوب but when I click on this links it shows:...