Skip to content

Instantly share code, notes, and snippets.

View Manntrix's full-sized avatar
🏠
Working from home

React Developer Manntrix

🏠
Working from home
View GitHub Profile
import React from 'react';
import logo from './logo.svg';
import './App.css';
import Users from './components/users/users'
function App() {
return (
<div className="App">
<Users></Users>
</div>
@Manntrix
Manntrix / users.js
Last active May 1, 2020 18:25
users.js
import React, {Component} from 'react'
import axios from '../../axios'
export default class users extends Component {
constructor(props) {
super(props);
this.state = {
Users: []
};
}
import React, {Component} from 'react'
import axios from '../../axios'
export default class users extends Component {
constructor(props) {
super(props);
this.state = {
Users: []
};
}
receivedData() {
axios
.get(`https://jsonplaceholder.typicode.com/photos`)
.then(res => {
const data = res.data;
const slice = data.slice(this.state.offset, this.state.offset + this.state.perPage)
const postData = slice.map(pd => <React.Fragment>
<p>{pd.title}</p>
<img src={pd.thumbnailUrl} alt=""/>
handlePageClick = (e) => {
const selectedPage = e.selected;
const offset = selectedPage * this.state.perPage;
this.setState({
currentPage: selectedPage,
offset: offset
}, () => {
this.receivedData()
});
<div>
{this.state.postData}
<ReactPaginate
previousLabel={"prev"}
nextLabel={"next"}
breakLabel={"..."}
breakClassName={"break-me"}
pageCount={this.state.pageCount}
marginPagesDisplayed={2}
pageRangeDisplayed={5}
@Manntrix
Manntrix / app.js
Last active February 1, 2021 06:10
import React, {Component} from 'react'
import axios from 'axios'
import ReactPaginate from 'react-paginate';
import './App.css'
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
offset: 0,
.pagination {
margin: 15px auto;
display: flex;
list-style: none;
outline: none;
}
.pagination > .active > a{
background-color: #47ccde ;
border-color: #47ccde ;
color: #fff;
<AliceCarousel autoPlay autoPlayInterval="3000">
<img src={image1} className="sliderimg"/>
<img src={image2} className="sliderimg"/>
<img src={image3} className="sliderimg"/>
<img src={image4} className="sliderimg"/>
</AliceCarousel>
constructor(props, context) {
super(props, context);
this.state = {
galleryItems: [],
};
}
getData (){
axios.get(`https://picsum.photos/v2/list?limit=6`, {})
.then(res => {
const data = res.data