Skip to content

Instantly share code, notes, and snippets.

import { List, fromJS } from 'immutable';
/**
* make size 9 array of 0s
* @returns {Array}
*/
function makeCountObject() {
const countObj = [];
for (let i = 0; i < 10; i += 1) countObj.push(0);
return countObj;
}
const puzzle = [
[cell, cell, cell, cell, cell, cell, cell, cell, cell],
[cell, cell, cell, cell, cell, cell, cell, cell, cell],
[cell, cell, cell, cell, cell, cell, cell, cell, cell],
[cell, cell, cell, cell, cell, cell, cell, cell, cell],
...
]
getSelectedCell() {
const { board } = this.state
const selected = board.get('selected')
return selected && board.get('puzzle').getIn([selected.x,selected.y])
}
renderCell(cell, x, y) {
const { board } = this.state
const selected = this.getSelectedCell()
const sameValue = selected && selected.get('value') && value === selected.get('value')
class Game extends Compoent {
...
getSelectedCell() {
const { board } = this.state;
const selected = board.get('selected');
return selected && board.get('puzzle').getIn([selected.x, selected.y]);
}
selectCell = (x, y) => {
let { board } = this.state
const cell = {
value: 9,
notes: Set([1,2,3]),
prefilled: false
}
const Cell = (props) => {
const {
value, onClick, isPeer, isSelected, sameValue, prefilled, notes, conflict,
} = props;
const backgroundColor = getBackGroundColor({
conflict, isPeer, sameValue, isSelected,
});
const fontColor = getFontColor({ conflict, prefilled, value });
return (
<div className="cell" onClick={onClick}>
debugger
console.log(document.cookie)
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { fetchAudioFeaturesById } from '../actions';
import Artist from '../Artist'
const mapStateToProps = ...
const mapDispatchToProps = ...
class ConnectedArtist extends React.Component {
...
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { fetchAudioFeaturesById } from '../actions';
// stateless template for the display
import AudioFeatures from '../AudioFeatures'
const mapStateToProps = ({audioFeaturesById}, {trackId}) => ({
audioFeatures: audioFeaturesById[trackId]
});
import React, { Component } from 'react';
import { connect } from 'react-redux';
import withRedux from '../nextWithReduxWrapper';
import { FETCH_PLAY_HISTORY } from '../actions';
import PlayHistory from '../components/PlayHistory';
const mapStateToProps = ({ history, artistsById, audioFeaturesById }) => {
return { history, artistsById, audioFeaturesById };
};