Day: January 5, 2018

Create Stateless functional component for ReactJS

This is another way to create React components. Stateless functional component is JS pure functions which has no state. This is the product component which I have created using createReactClass method

Now we will see how we can convert above code to stateless function component So this is the syntax for stateless function is […]

Read more

ES6 Class component for React

You can use ES6 to create ReactJS component. We will create the following code in ES6 syntsax

You can see the following code snippet which I have rewritten with ES6 syntax. Here I am extending the React.component to create your Product component. You can see it at line 4

Read more

Add method to React component

Now we will see how to add method to React component. If you are not familiar with creating React component you can refer this tutorial I have the following code inside the index.js file

Then I will create method in my component file product.js

You can see the calculateDiscount() method in code and […]

Read more

Add properties to the component

Previous tutorial we studied how to create React component. Now we will see how to add properties to the component You can add dicount property to the Products component as shown in the below code and I have passed the value of discount as 10

Now lets see how we can display the property […]

Read more