Last active
February 3, 2020 06:25
-
-
Save tariqulislam/609358a346fc85045eda56252f411f7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ./routes/Home.js | |
import React, {Component} from 'react' | |
export class Home extends Component { | |
/* Add the contructor to initialize the local state of the component */ | |
constructor(props) { | |
super(props) | |
/* initial the state for component */ | |
this.state = { | |
articles: [ | |
{title: "React Redux tutorial 1", id:1}, | |
{title: "Typescript Tutorial for beginners", id:2} | |
]} | |
} | |
render () { | |
/* distracting the articles array from state */ | |
const {articles} = this.state | |
return (<ul>{ | |
/* show the item in list using map function javascript */ | |
articles.map(el => <li key={el.id}>{el.title}</li>) | |
}</ul>) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment