Coder Social home page Coder Social logo

chototoss / react-paginating Goto Github PK

View Code? Open in Web Editor NEW
98.0 6.0 14.0 2.23 MB

Simple, lightweight, flexible pagination ReactJS component ⏮⏪1️⃣2️⃣3️⃣⏩⏭

Home Page: https://chototoss.github.io/react-paginating/

License: MIT License

JavaScript 93.95% HTML 6.05%
paginate pagination paginator pagination-components function-as-child react reactjs typescript flowtype cypress

react-paginating's Introduction

React Paginating

ci/cd cypress

jest Download monthly codecov npm version License: MIT PRs Welcome

gzip size module formats Package Quality

Package Quality

Motivation

During development, we were facing problems supporting server-rendering of our web app & SEO (require pagination links). To solve that, we had to add 2 snippets of code, one to support the server-side and another to support the client-side which lead to being hard for maintenance. Most of the pagination libraries only support client-rendering by attaching event handlers on the pagination button to redirect. Because of that, we created this library which allows flexibly to customize behaviors (attaching event handlers or href attribute) and user interface.




The component applied Render Props pattern. (You can read more about this pattern here).

This approach allows you to fully control UI component and behaviours.

See the intro blog post

Table content

Installation

npm install --save react-paginating

or

yarn add react-paginating

Usage

You can check out the basic demo here:

.bg-red {
  background-color: red;
}
import React from 'react';
import { render } from 'react-dom';
import Pagination from 'react-paginating';

const fruits = [
  ['apple', 'orange'],
  ['banana', 'avocado'],
  ['coconut', 'blueberry'],
  ['payaya', 'peach'],
  ['pear', 'plum']
];
const limit = 2;
const pageCount = 3;
const total = fruits.length * limit;

class App extends React.Component {
  constructor() {
    super();
    this.state = {
      currentPage: 1
    };
  }

  handlePageChange = (page, e) => {
    this.setState({
      currentPage: page
    });
  };

  render() {
    const { currentPage } = this.state;
    return (
      <div>
        <ul>
          {fruits[currentPage - 1].map(item => <li key={item}>{item}</li>)}
        </ul>
        <Pagination
          className="bg-red"
          total={total}
          limit={limit}
          pageCount={pageCount}
          currentPage={currentPage}
        >
          {({
            pages,
            currentPage,
            hasNextPage,
            hasPreviousPage,
            previousPage,
            nextPage,
            totalPages,
            getPageItemProps
          }) => (
            <div>
              <button
                {...getPageItemProps({
                  pageValue: 1,
                  onPageChange: this.handlePageChange
                })}
              >
                first
              </button>

              {hasPreviousPage && (
                <button
                  {...getPageItemProps({
                    pageValue: previousPage,
                    onPageChange: this.handlePageChange
                  })}
                >
                  {'<'}
                </button>
              )}

              {pages.map(page => {
                let activePage = null;
                if (currentPage === page) {
                  activePage = { backgroundColor: '#fdce09' };
                }
                return (
                  <button
                    {...getPageItemProps({
                      pageValue: page,
                      key: page,
                      style: activePage,
                      onPageChange: this.handlePageChange
                    })}
                  >
                    {page}
                  </button>
                );
              })}

              {hasNextPage && (
                <button
                  {...getPageItemProps({
                    pageValue: nextPage,
                    onPageChange: this.handlePageChange
                  })}
                >
                  {'>'}
                </button>
              )}

              <button
                {...getPageItemProps({
                  pageValue: totalPages,
                  onPageChange: this.handlePageChange
                })}
              >
                last
              </button>
            </div>
          )}
        </Pagination>
      </div>
    );
  }
}

render(<App />, document.getElementById('root'));

Examples

Input Props

total

number

Total results

className

string

Customizable style for pagination wrapper

limit

number

Number of results per page

pageCount

number

How many pages number you want to display in pagination zone.

currentPage

number

Current page number

Child callback functions

getPageItemProps

function({ pageValue: number, onPageChange: func })

Allow to pass props and event to page item. When page is clicked, onPageChange will be executed with param value pageValue.

Note: This callback function should only use for paging with state change. If you prefer parsing page value from query url (Please don't use this callback function).

Controlled Props

pages

array: [number]

List of pages number will be displayed. E.g: [1, 2, 3, 4, 5]

currentPage

number

previousPage

number

nextPage

number

totalPages

number

hasNextPage

boolean

Check if it has next page or not.

hasPreviousPage

boolean

Check if it has previous page or not.

Alternatives

If you don’t agree with the choices made in this project, you might want to explore alternatives with different tradeoffs. Some of the more popular and actively maintained ones are:

Contributors


Dzung Nguyen

📖 💻 🤔 👀 🐛

Chau Tran

💻 🤔 👀 🐛

Faris Abusada

💻 🐛

react-paginating's People

Contributors

davidnguyen11 avatar greenkeeper[bot] avatar nartc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-paginating's Issues

Add document site

Set up a small app in site the repo to create a document and apply react-paginating.github.io to point to the document

Example using React Hooks

Hi, I'm new to React and I would like to use this component as a Hook instead of normal Class. Is there a working example I can view?

Thanks

upgrade babel from version 6 to 7

Describe the issue
Upgrade babel from version 6 to 7

Solution
install packages
presets

  • @babel/core
  • @babel/preset-env
  • @babel/preset-react

plugins

  • @babel/plugin-proposal-class-properties

and update .babelrc as follow:

{
  "presets": [
    "@babel/preset-env",
    "@babel/preset-react"
  ],
  "plugins": [
    "@babel/plugin-proposal-class-properties"
  ]
}

[Discussion] React Native implementation

Pagination UX/UI on Mobile devices does not necessarily look and feel like Pagination on Web. This library (https://github.com/garrettmac/react-native-pagination) provides great examples on how one would implement Pagination on mobile devices.

However, for this particular library, I could think of one immediate use-case is to wrap a list (FlatList for example) in the Pagination component and implement onReachedEnd() (I think that's what the method's called, could be completely off but the point is this method is called when the list reaches the end and asking for more data).

What do you guys think? Any other suggetions on how pagination should be on mobile devices?

An in-range update of rollup-plugin-terser is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency rollup-plugin-terser was updated from 5.2.0 to 5.3.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

rollup-plugin-terser is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of all-contributors-cli is breaking the build 🚨

The devDependency all-contributors-cli was updated from 6.13.0 to 6.14.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

all-contributors-cli is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v6.14.0

6.14.0 (2020-02-23)

Features

  • alpha-sort: Add a parameter contributorsSortAlphabetically (#249) (b3d0995)
Commits

The new version differs by 5 commits.

  • b3d0995 feat(alpha-sort): Add a parameter contributorsSortAlphabetically (#249)
  • 8dd551a chore(package): update nock to version 12.0.0 (#248)
  • 80b1fbd Update pify to the latest version 🚀 (#247)
  • 07099de chore(deps): update inquirer to the latest version 🚀 (#245)
  • 3c124bf Update kcd-scripts to the latest version 🚀 (#244)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of rollup-plugin-babel is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency rollup-plugin-babel was updated from 4.3.3 to 4.4.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

rollup-plugin-babel is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 2 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Please release

Could you please release a new version with those improved typings?

[Discussion] Getting rid of UNSAFE Life Cycles in master branch

As stated in the title, we should try getting rid of UNSAFE Life Cycle methods that are being used in master branch. As far as I understand, we would want to update the state.currentPage to this.props.currentPage if this.props.currentPage is not null AND this.props.currentPage is different than current state.currentPage.

We can actually use static getDerivedStateFromProps for this and get rid of the two UNSAFE componentWill... methods.

Here's a proposal:
image

An in-range update of eslint-plugin-react is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency eslint-plugin-react was updated from 7.18.3 to 7.19.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 14 commits.

  • e2ed536 Update CHANGELOG and bump version
  • 5959b5f [fix] prefer-stateless-function: avoid crash on ts empty constructor
  • e231f44 [tests] no-unescaped-entities: skip test cases that are now parsing errors in [email protected]
  • 434b45f [Dev Deps] update @types/eslint, @types/estree, @types/node, eslint-plugin-eslint-plugin, eslint-plugin-import, typescript
  • a917dda [Deps] update resolve, xregexp
  • 09608cc [Fix] no-adjacent-inline-elements: avoid a crash
  • b833535 [Fix] no-unused-prop-types: Change the reporting to point to a more accurate node
  • edc5fe2 [New] style-prop-object: Add allow option
  • 9b5d6aa [Fix] self-closing-comp: consider JSXMemberExpression as component too
  • 598277e [New] jsx-pascal-case: Support unicode characters
  • 43e466c [readme] Small visual inconsistency
  • 03edb68 [docs] add react/ prefix to rule name, for consistency
  • b517b9e [Fix] no-unused-prop-types: make markPropTypesAsUsed work with TSEmptyBodyFunctionExpression AST node
  • 66c0d66 [Fix] displayName (but really, propTypes detection): do not crash on empty flow type spreads

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Missing propTypes

Describe the bug
Missing propTypes at Pagination.js.

Solution
Revert the propTypes from the old version.

Some dependencies should be dev-only

When trying to run my react-scripts based app after upgrading this package to its latest version, I get a warning:

The react-scripts package provided by Create React App requires a dependency:

  "babel-loader": "8.0.5"

Looking at the changes, this commit appears to have moved a number of dependencies from dev to normal when upgrading them. Leaving this as-it would mean that any react-scripts app that uses a different version of that package would be unable to depend on this one.

Error when pass Controlled Props as string

Describe the bug
Error when pass Controlled Props as string on server side using Nextjs 8

To Reproduce
Steps to reproduce the behavior:
<Pagination
total={'this is string'}
currentPage={'10'} />

Expected behavior

  • Should output error message to developer
  • Should accept string number. Example:
    "10", '2'

many warnings while installing

\uno>npm install --save react-paginating
npm WARN rollback Rolling back [email protected] failed (this is probably harmless): EPERM: operation not permitted, lstat 'C:\REACT\uno\node_modules\jest-haste-map\node_modules\fsevents\node_modules'
npm WARN @typescript-eslint/[email protected] requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/[email protected] requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/[email protected] requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of [email protected] - 3 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of popper.js@^1.14.7 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\jest-haste-map\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

New prop totalPages and make props (total, limit) as optional

Describe the bug
Basically, my API endpoint will be like: http://localhost:3000/api/items?page=2
which accepts query currentPage is 2, and returns items, totalPages (eg. 20 pages)
Obviously, I don't have to and don't need to provide total and limit to your Component.

In the other hand, if I provide total and limit, I don't need to provide totalPages

By the way, pageCount props name is very confusing, could you rename it to something clearer, like pagesDisplayCount

Add support minified `iife` format.

Describe the issue
Add support minified iife format.

Solution

packge.json
Add postbuild command

"scripts": {
    ...,
    "postbuild": "BUILD_MINIFY=true rollup --config"
    ...,
}

rollup.config.js
Install package terser & modify the rollup config.

import babel from 'rollup-plugin-babel';
import { terser } from 'rollup-plugin-terser';

const isMinify = process.env.BUILD_MINIFY ? true : false;

let output = [
  {
    file: 'dist/react-paginating.cjs.js',
    name: 'react-paginating-cjs',
    format: 'cjs'
  },
  {
    file: 'dist/react-paginating.esm.js',
    name: 'react-paginating-esm',
    format: 'esm'
  },
  {
    file: 'dist/react-paginating.umd.js',
    name: 'react-paginating-umd',
    format: 'umd',
    sourcemap: true
  },
];

if (isMinify) {
  output = {
    file: 'dist/react-paginating.umd.min.js',
    name: 'react-paginating.umd.min',
    format: 'iife',
    sourcemap: true
  };
}

export default [{
  input: 'src/Pagination/index.js',
  output,
  plugins: [
    babel({
      exclude: 'node_modules/**'
    }),
    isMinify ? terser() : null
  ]
}];

An in-range update of react is breaking the build 🚨

There have been updates to the react monorepo:

    • The dependency react was updated from 16.12.0 to 16.13.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the react group definition.

react is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for 16.13.0 (February 26, 2020)

React

  • Warn when a string ref is used in a manner that's not amenable to a future codemod (@lunaruan in #17864)
  • Deprecate React.createFactory() (@trueadm in #17878)

React DOM

Concurrent Mode (Experimental)

Artifacts

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of sinon is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency sinon was updated from 9.0.0 to 9.0.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

sinon is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 23 commits.

  • d2b4b72 Update docs/changelog.md and set new release id in docs/_config.yml
  • c99f6ea Add release documentation for v9.0.1
  • 0fe75bf 9.0.1
  • e24b7e7 Update CHANGELOG.md and AUTHORS for new release
  • 00b40a6 Upgrade @sinonjs/samsam to latest
  • decaec6 Upgrade @sinonjs/formatio to latest
  • 775e53b Merge pull request #2237 from fatso83/issue-2226
  • 92dc087 Remove needless intermediary
  • 25311e4 Simplify sandbox fix by reusing the fix for stubs
  • 1fe433e [fix] stubs restore prototype props correctly
  • 3031027 Add custom prop isOwn to descriptor
  • 49abbad Rename util
  • 4b55c62 [fix] sandbox.restore handles protype props
  • aac0bc3 Add verification tests for #2226
  • 5436466 Bump @sinonjs/commons from 1.7.0 to 1.7.1

There are 23 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of babel7 is breaking the build 🚨

There have been updates to the babel7 monorepo:

    • The devDependency @babel/core was updated from 7.8.4 to 7.8.6.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the babel7 group definition.

babel7 is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

add rollup to replace the build process

Describe the issue
Apply rollup to replace the build process.

Expected behavior
Using the rollup to release to manage the build process. It supports 3 types of module.

  1. react-paginating.umd.js (main file)
  2. react-paginating.esm.js
  3. react-paginating.cjs.js

Actual behavior
It uses the "babel cli" to compile the ES6 code to ES5 code.

An in-range update of rollup is breaking the build 🚨

The devDependency rollup was updated from 1.31.1 to 1.32.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v1.32.0

2020-02-28

Features

  • Allow adding plugins on the command line via --plugin <plugin> (#3379)

Pull Requests

Commits

The new version differs by 8 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of react-scripts is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency react-scripts was updated from 3.4.0 to 3.4.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

react-scripts is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v3.4.1

3.4.1 (2020-03-20)

v3.4.1 is a maintenance release that includes minor bug fixes and documentation updates including upgrading Babel to fix a bug in the 7.8 release line. This release also brings support for TypeScript 3.8.

🐛 Bug Fix

  • react-scripts
  • babel-preset-react-app
  • cra-template, eslint-config-react-app, react-scripts
    • #7790 Widen eslint-config-react-app peer dependency versions (@lukyth)

💅 Enhancement

  • cra-template-typescript, cra-template
  • react-scripts

📝 Documentation

  • Other
    • #8515 Fix proxying API request docs (@hjr3)
    • #8561 Indicate that the file structure is the template's (@Vinnl)
  • react-scripts

🔨 Underlying Tools

  • babel-preset-react-app, create-react-app, react-dev-utils, react-error-overlay, react-scripts
  • react-scripts

Committers: 9

Migrating from 3.4.0 to 3.4.1

Inside any created project that has not been ejected, run:

npm install --save --save-exact [email protected]

or

yarn add --exact [email protected]
Commits

The new version differs by 13 commits.

  • d2f813f Publish
  • 7641a3c Prepare 3.4.1 release
  • d5b527f Update to Babel 7.9 (#8681)
  • 6adb82a Add React.StrictMode to default templates (#8558)
  • a452ddc Bump dependencies (#8620)
  • 3f699fd Fix proxying API request docs (#8515)
  • 4d26208 Use native ESLint behaviour when extending (#8276)
  • 8ba0ccb Whitelist main in template.json (#8539)
  • 7d3b72c Update template example in docs (#8561)
  • 2030ee1 Fix optional chaining and nullish coalescing support (#8526)
  • 038e6fa Widen eslint-config-react-app peer dependency versions (#7790)
  • 7e6d6cd Closes webpack dev server and exits process on "end" stdin (#7203)
  • af926d5 Bump pnp-webpack-plugin (#8509)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

[Feature Request] Provide a method to construct proper data for the Pagination component

From the example as of the moment, developers would have to construct their data into an array of array to conform with the usage of this library. I don't really think it's developer-friendly that way. A developer should only concern with the data that they get an external source (API, file etc...).

Hence, I'm submitting a feature request for a method that will: take in an Array and a limit integer and will return a new Array with the proper format.

function getData(array, perPage) {
   ...
}

Also, I think that limit is a bit odd name for what it really is. Should it be perPage? or itemsPerPage?

add flow-typed support

Describe the issue
Add flow-typed support

Solution
Use Flowgen to migrate the Typescript declaration file to flow-typed file.

Update declaration file & flow-typed

Describe the issue
Update typescript declaration & flow-type files.

Solution

  1. Change from class declaration to function and use React.SFC.
  2. Use flowgen to update the flow-typed file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.