Create A Dating Site In React

Posted on
Create A Dating Site In React Average ratng: 8,7/10 1787 reviews

DatePicker dialog is used to pick date in Android and iOS applications. By default react native has two different DatePicker component 1st one is DatePickerIOS and 2nd is DatePickerAndroid, but it is very difficult to configure two component for single task. So after finding a lot on Internet finally i found an immersive library called as react-native-datepicker-dialog . This library comes with an awesome functionality that using a single code developers can create DatePicker for both android and iOS applications. So let’s get started 🙂 .

Contents in this project React Native Common DatePicker for Android and iOS tutorial :

Create A Dating Site In React App

1. Start a fresh React Native project. If you don’t know how then read my this tutorial.

Create react app is a starter kit that helps to start a React website without learning and configuring many build tools. You don’t need to rebuild the whole application when developing. Instant reloads do all the work for you. Under the hood, Create react app use Webpack, Babel, ESLint, and other projects. React datepicker is reusable datepicker component. React does not have a datepicker module but we can use the react-datepicker third-party library.

  • Nov 16, 2021 So, after a successful installation of Node.js, create a React application using NPX. Npx create-react-app react-multi-page-website. This command will create a react application with the project name react-multi-page-website. Now enter the project directory and start the app. Cd react-multi-page-website npm start. It will open up the React application we have created in our browser window with the address The port may vary if 3000 is busy.
  • The production build has all the tools necessary to generate a first-class.

2. Add react-native-datepicker-dialog library inside your project :

Open Your project in command prompt and execute below command inside your project’s folder.

3. After successfully installed the react-native-datepicker-dialog library we need to install another library known as moment. To install the moment library inside your project execute the below command in project’s folder.

4. Import AppRegistry, StyleSheet, Text, View, TouchableOpacity in your project.

2
import{DatePickerDialog}from'react-native-datepicker-dialog'
import moment from'moment';

6. Create constructor in your main class with props and define two variables DateText and DateHolder using state.

DateText : is used to show date on screen using Text component.

DateHolder : is used to get date from DatePicker dialog.

2
4
6
8
10
12
14
16
18
20
this.setState({
});
this.refs.DatePickerDialog.open({
date:DateHolder,
});
}

8. Create another function named as onDatePickedFunction() with date argument inside it. This function would call after the DatePickerMainFunctionCall(). Using this function we would set the pick date in Text component.

2
4
6
8
10
12
14
16
18
20
22
24
26
return(
<TouchableOpacity onPress={this.DatePickerMainFunctionCall.bind(this)}>
<View style={styles.datePickerBox}>
<Text style={styles.datePickerText}>{this.state.DateText}</Text>
</View>
</TouchableOpacity>
{/* Place the dialog component at end of your views and assign the references, event handlers to it.*/}
<DatePickerDialog ref='DatePickerDialog'onDatePicked={this.onDatePickedFunction.bind(this)}/>
</View>
}

10. Create CSSStylesheet for all views.

Dating
AppRegistry.registerComponent('Mainproject',()=>Mainproject);

12. Complete source code for index.android.js / index.ios.js file