목록전체 글 (374)
Silver Library (Archived)
An example of a simple render() function that creates a list of elements using the map() function, and assigns a unique key to each item in the list: import React from 'react'; class MyComponent extends React.Component { render() { const items = ['item 1', 'item 2', 'item 3']; return ( {items.map((item, index) => {item})} ); } } In this example, the render() function creates an array of strings ..
Suppose you installed react with npx create-react-app and install typescript on it as well. And you need a quick solution of it. Here is how I did. npm install --save typescript @types/node @types/react @types/react-dom @types/jest Add tsconfig.json with tsc --init Modify App.js and index.js to tsx. You will see errors. This means you need to define types for its error to be removed. Index.tsx w..
Let's see how it would look like with class and functional component each. // class based component class AnimeComponent extends React.Component { constructor(props) { super(props)' this.state = { count: 0 }; this.handleClick = this.handleClick.bind(this); } handleClick() { this.setState(state => ({ count: state.count + 1 })); } render() { return ( Clicked {this.state.count} times. ); } } // fun..
Note: this post is a scrapped version of explained pagination. See the link below to read the original text. Basic concept: we need as props to our Pagination component: totalCount: represents the total count of data available from the source. currentPage: represents the current active page. We'll use a 1-based index instead of a traditional 0-based index for our currentPage value. pageSize: rep..