Giter Site home page Giter Site logo

pager's Introduction

DEPRECATED Stateless Pager component

Code Climate Build Status
NPM version

Deprecation notice

Now all my free time is spent on react-ui-generator, which is my main project. So, I don't have any more time to maintain this package. Please, fill free to fork this repository.

Getting started

import React from 'react';
import { render } from 'react-dom';
import Pager from 'react-pager';

class App extends React.Component {
	constructor(props) {
		super(props);

		this.handlePageChanged = this.handlePageChanged.bind(this);

		this.state = {
			total:       11,
			current:     7,
			visiblePage: 3,
		};
	}

	handlePageChanged(newPage) {
		this.setState({ current : newPage });
	}

	render() {
		return (
			<Pager
				total={this.state.total}
				current={this.state.current}
				visiblePages={this.state.visiblePage}
				titles={{ first: '<|', last: '>|' }}
				className="pagination-sm pull-right"
				onPageChanged={this.handlePageChanged}
			/>
		);
	}
}

window.onload = () => {
	render(React.createElement(App), document.querySelector('#app'));
};

What it looks like*

First | Prev | ... | 6 | 7 | 8 | 9 | ... | Next | Last

* Bootstrap 3.0 is required by default, but you can replace it with your own css.

Demo

Just open demo/index.html in your browser. Or see interactive demo here.

Tests

npm test

Changelog

v1.3.0

  • @kallaspriit fixed #16
  • Updates devDependencies
  • Move building procedure to Docker

v1.2.1

v1.2.0

  • Rewrited all to ES6.
  • Switched from gulp + browserify to webpack.
  • Now officially supports only React >= 15.0.0

v1.1.4

  • Updated to React 15. Thanks to contributors!

v1.1.1

  • Updated to React 0.13.
  • Updated local demo.

v1.1.0

  • Added titles property. See demo.
  • Improved building script.

v1.0.6

  • Fixed <li class="undefined" .. in "more" and "less" buttons.
  • Added a few unit-tests.

Contributors

See contributors.

pager's People

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

Watchers

 avatar  avatar

pager's Issues

Errors when using pager with react 0.13

When using react-pager with react version 0.13.0, I get the following errors:

Warning: Something is calling a React component directly. Use a factory or JSX instead. See: http://fb.me/react-legacyfactory dist.js:38208 Warning: Pager(...): Norendermethod found on the returned component instance: you may have forgotten to definerenderin your component or you may have accidentally tried to render an element whose type is a function that isn't a React component. dist.js:18563 Warning: Don't set the props property of the component. Mutate the existing props object instead. dist.js:24920 Uncaught TypeError: Can't add property context, object is not extensible

I have a demo application that shows the problem. You can find it here:
https://github.com/jeffbarge/react-pager-problem

Support for React 16

Will component be available in react 16?

$ npm install
+-- UNMET PEER DEPENDENCY [email protected]
+-- UNMET PEER DEPENDENCY [email protected]
`-- [email protected]

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\react-scripts\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: fsevents@^1.0.0 (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 [email protected] requires a peer of react@^15.0.0 but none was installed.
npm WARN [email protected] requires a peer of react-dom@^15.0.0 but none was installed.

I have tested it by copying sources into application and seems it works perfectly. No backward incompatibilities found.

Publish new version

Howdy - could you publish a version with the [email protected] support? You modified package.json to allow the new version of react but haven't pushed to npm yet. ๐Ÿ˜„

npm version patch -m "Bump version" && npm publish && git push origin master --tags ๐Ÿ˜‰ โค๏ธ

babel-preset-latest is deprecated

When I try to build my project I get this message:

Module build failed: Error: Couldn't find preset "latest" relative to directory "/mydir/node_modules/react-pager"

Installing babel-preset-latest fixes the error, but I think it's not the best way because babel-preset-latest is deprecated and its installation gives me a warning:

We're really excited that you're trying to use ES2016 syntax, but instead of making more yearly presets, Babel has a better preset that we recommend you use instead: npm install babel-preset-env --save-dev. Give us a follow @babeljs to get more updates

However, installing only babel-preset-env doesn't fix the problem.

active class is not showing

Hi, I have used this pager, but the active class of is not working after clicking, how should I to fix it?
I just install the react-pager, than import it and put the tag on my view.
Thanks in advance!

Accessibility: Pagination links cannot receive focus

This pager currently doesn't add href or tabIndex to its links, which makes it substantially more difficult for users to navigate pages with the keyboard.

Proposed Solution

Add hrefs to the links in the render method of the Page class and update the handlers to call preventDefault on the event.

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.