Skip to content

Instantly share code, notes, and snippets.

View olegkalyta's full-sized avatar

Oleg Kalyta olegkalyta

View GitHub Profile
const SingleRule = new GraphQLObjectType({
name: 'SingleRule',
description: 'Single validation rule',
fields: () => ({
id: {
type: GraphQLID,
description: 'ID of rule'
},
fieldName: {
type: GraphQLString,
@olegkalyta
olegkalyta / file_1_react-boostrap-table-steps-to-reproduce.js
Last active February 1, 2018 09:00
React-Bootstrap-Table adding remote breaks sorting, first file shows how to reproduce it, second file - how I fix it now
import React, { Component } from 'react'
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table'
import '../node_modules/react-bootstrap-table/dist/react-bootstrap-table-all.min.css'
const data = [
{
id: 0,
name: 'Oleg',
yearBorn: 1988,
},
import { FetchDropdownData, FetchUsers, FetchProposals } from './Fetchers'
import ProposalsView from './ProposalsView'
export default () => (
<FetchDropdownData>
<FetchUsers>
<FetchProposals>
<ProposalsView />
</FetchProposals>
</FetchUsers>
const newProps = { ...rest }
if (mapFetchedDataTo) {
delete newProps.data
newProps[mapFetchedDataTo] = this.props.data
}
const chidlrenWithProps = cloneElement(children, newProps)
const dataValidationErrors = this.getRequiredDataErrors()
// reducer
initialState = {
isFetching: false,
error,
programs
}
// ProgramsController
import Loadable from './Loadable'
class LoadableContainer extends Component {
componentDidMount() {
const { fetchData, data } = this.props
if (!data) {
fetchData()
}
}
render() {
const { children, isFetching, error, fetchData, ...rest } = this.props
import React, { Component, Children } from 'react'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'
import { fetchPrograms } from '../../modules/loanPrograms'
class LoanProgramContainer extends Component {
componentDidMount() {
this.props.fetchPrograms()
}
var container = {
context: [],
canvas: [],
gameArea: null,
width: 0,
height: 0,
unitSize: 0,
init: function () {
function findMaxZerosFrom(arr, index) {
let zerosLength = 1
let nextElement = arr[index + 1]
while(nextElement === '0') {
index++
zerosLength++
nextElement = arr[index + 1]
}
@olegkalyta
olegkalyta / question.js
Created October 21, 2016 07:49
Ask Dan
function patchStoreToAddLogging(store) {
let next = store.dispatch
store.dispatch = function dispatchAndLog(action) {
console.log('dispatching', action)
let result = next(action)
console.log('next state', store.getState())
return result
}
}