npm install --save alternate
const alternate = require('alternate');
const a = new alternate(true, false);
// .next()
a.next() // returns true
a.next() // returns false
a.next() // returns true
a.next() // returns false
// .peek()
a.peek() // returns true
a.peek() // returns true
a.next() // returns true
a.peek() // returns false
a.peek() // returns false
const alternate = require('alternate');
const a = new alternate('one', 'two', 3, 4);
a.next() // returns 'one'
a.next() // returns 'two'
a.next() // returns 3
a.next() // returns 4
a.next() // returns 'one'
import React from 'react';
import Alternate from 'alternate';
const rows = ['row1', 'row2', 'row3', 'row4'];
const Table = () => {
const alternateRowColor = new Alternate('red', 'yellow');
return (
<div>
{rows.map(row => (
<div style={{ backgroundColor: alternateRowColor.next() }}>
{row}
</div>
))}
</div>
);
};
export default Table;