Sunday, 24 March 2019
Sunday, March 24, 2019
Server Side Pagination in ASP.NET MVC
Sunday, 3 March 2019
Sunday, March 03, 2019
State and Props in React Native Application
In this Article, we will see How to use State and Props in React Native Application. If you are new to React Native, then I will recommend you to read the previous article of this series.
In React (or React Native), there are two types of data that can control a component. One is State and another is Props.
State: State can be referred as the local state of the component. State of a component cannot be accessed and modified outside of the component. State is mutable, which means that the state of a component can be changed in response to some action. State of one component can behave as Props for the other component as well. We cannot update the state directly, in order to update the state of the component, we have to use setState method. setState will re-render the parent component as well as the child component class.
Let’s see How we can use state in React Native Application.
App.js Code:
In the above example, we have created state object and added a Counter property with initial value as 1. We have declared updateState function in order to update the state using the setState method. On calling setState, it will re-render the Component. On the Text component, we are using onPress Touch event which will can the updateState function and increase the counter value with 1. Now let’s run the application with npm Start command.
Preview:
Props: Props stands for the properties and used to pass data as well as an event handler to the child components (passing data from the view to the controller or from parent to the child). It is immutable that means we cannot change its value and have fast performance than the state. Let’s do some changes in the previous example in order to check its functionality. In order to demonstrate we need two Classes, one will behave as parent and other will behave as child.
App.js
In the above code, we are importing the Child class (code for the Child class is provided below) and passed Counter value(as myCounter attribute in JSX) as well as function (as updateState atribute) for the updating the State as props.
ChildApp.js:
As we know, our Child class is receiving multiple props so we can use this.props.<Name_Of_Property> in order to access its value.
Preview:
Hope this will help you.
Thanks.
In React (or React Native), there are two types of data that can control a component. One is State and another is Props.
State: State can be referred as the local state of the component. State of a component cannot be accessed and modified outside of the component. State is mutable, which means that the state of a component can be changed in response to some action. State of one component can behave as Props for the other component as well. We cannot update the state directly, in order to update the state of the component, we have to use setState method. setState will re-render the parent component as well as the child component class.
Let’s see How we can use state in React Native Application.
App.js Code:
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default class App extends React.Component {
state = {
Counter: 1
}
updateState = () =>
this.setState({ Counter: this.state.Counter + 1 })
render() {
return (
<View style={styles.container}>
<Text style={{ fontSize: 40 }}>State Example</Text>
<Text style={{ fontSize: 40 }} onPress={this.updateState}>
{this.state.Counter}
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
|
Preview:
Props: Props stands for the properties and used to pass data as well as an event handler to the child components (passing data from the view to the controller or from parent to the child). It is immutable that means we cannot change its value and have fast performance than the state. Let’s do some changes in the previous example in order to check its functionality. In order to demonstrate we need two Classes, one will behave as parent and other will behave as child.
App.js
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Child from './ChildApp';
export default class App extends React.Component {
state = {
Counter: 1
}
updateState = () => this.setState({ Counter: this.state.Counter + 1 })
render() {
return (
<View style={styles.container}>
<Child myCounter={this.state.Counter} updateState={this.updateState}></Child>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
|
ChildApp.js:
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default class Child extends React.Component {
render() {
return (
<View style={styles.container}>
<Text style={{ fontSize: 40 }}>Props Example</Text>
<Text style={{ fontSize: 40 }} onPress={this.props.updateState}>
{this.props.myCounter}
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
|
Preview:
Hope this will help you.
Thanks.
Tuesday, 18 December 2018
Tuesday, December 18, 2018
Create Hello World Application using React Native
In this Article, we will learn How to create the first application using React Native. We can create native mobile apps using JavaScript and React. It uses React in order to create rich mobile UI interfaces. As Stated on the React Native official Website,
“With React Native, you don’t build a “mobile web app”, an “HTML 5 app” or a “Hybrid App”. You build a real mobile app that’s indistinguishable from the app developed using Java or Objective-C. Native use the same fundamental blocks as in IOS and Android.”
“With React Native, you don’t build a “mobile web app”, an “HTML 5 app” or a “Hybrid App”. You build a real mobile app that’s indistinguishable from the app developed using Java or Objective-C. Native use the same fundamental blocks as in IOS and Android.”
Monday, 17 December 2018
Monday, December 17, 2018
How to Convert PST to Thunderbird MBOX
In this article, we will see How to Convert PST to Thunderbird MBOX.
This Article Includes:
This Article Includes:
- What is PST?
- What is MBOX?
- Why would you Convert PST to MBOX?
- Kernel for Outlook PST Repair
- Convert PST to MBOX
- Conclusion
Tuesday, 27 November 2018
Tuesday, November 27, 2018
MailsDaddy NSF to PST Converter
What is MailsDaddy NSF to PST Converter?
MailsDaddy NSF to PST Converter is a most desirable tool used to convert IBM Lotus Notes emails, contacts, calendar events, To-do lists, notes etc into Outlook PST format. It is a one-stop conversion solution of MailsDaddy Software and a powerful tool which performs a migration process of NSF to PST flawlessly and accurately. It extracts all the Lotus Notes information and exports it in Outlook compatible PST format.
Sunday, 18 November 2018
Sunday, November 18, 2018
DataTypes in MongoDB
In this article, we will learn about the Datatypes and its usage in the MongoDB. If you are new to MongoDB then I would recommend you to go through the previous article of the series:
- Part 1 - Getting started with MongoDB
- Part 2 - Configure a Windows Service for MongoDB
- Part 3 – Working with Database in MongoDB
Saturday, 20 October 2018
Saturday, October 20, 2018
Working with Database in MongoDB
In this article, we will learn about Database in MongoDB. Before starting, I would recommend you to go through the previous article in this series:









