View gist:5602186
StringBuilder sb = new StringBuilder(); | |
if (ConfigurationManager.AppSettings.HasKeys()) | |
{ | |
sb = new StringBuilder( "<ul style=\"list-style-type:none;\">" ); | |
foreach (string key in ConfigurationManager.AppSettings.Keys) | |
{ | |
sb.AppendFormat( "<li><strong>{0}</strong> - {1}</li>", key, ConfigurationManager.AppSettings[key] ); | |
} |
View GoodPropTypes.jsx
import propTypes from ‘prop-types’; | |
const propTypes = { | |
findDelay: PropTypes.number, | |
columns: PropTypes.array, | |
loadCollapsed: PropTypes.bool, | |
tableHeight: PropTypes.number, | |
rowHeight: PropTypes.number, | |
defaultColWidth: PropTypes.number, | |
}; |
View BadPropTypes.jsx
this.findDelay = typeof this.props.findDelay === 'number' ? this.props.findDelay : 500; | |
this.options = props.gridOptions; | |
this.options.columns = this.options.columns ? this.options.columns : []; | |
this.options.loadCollapsed = this.options.loadCollapsed ? this.options.loadCollapsed : false; | |
this.options.tableHeight = this.options.tableHeight ? this.options.tableHeight : 500;this.options.rowHeight = this.options.rowHeight ? this.options.rowHeight : 96; | |
this.defualtColWidth = this.options.columns.length ? `${100 / this.options.columns.length}%` : null; |
View StatelessFunctionalComponent.jsx
const HelloWorld = ({name}) => ( | |
<div>{`Hi ${name}`}</div> | |
); |
View BadStyles.jsx
<Modal | |
isOpen={this.props.isOpen} | |
className="wrapper no-select" | |
contentLabel="No Content Modal" | |
style={{overlay: {"backgroundColor": "transparent"}}}> |
View GoodStyles.jsx
# JSX | |
render() { | |
let hiddenClass = ''; | |
if (this.props.hideArrow) { | |
hiddenClass = 'hide'; | |
} | |
return ( | |
<button className={`filter-toggle ${hiddenClass}`} |
View SampleUnitTests.jsx
import React from 'react'; | |
import { shallow } from 'enzyme'; | |
import toJSON from 'enzyme-to-json'; | |
import StarRating from '../components/StarRating'; | |
describe('StarRating sharedComponent', () => { | |
it('should match a snapshot', () => { | |
const wrapper = shallow(<StarRating />); | |
expect(toJSON(wrapper)).toMatchSnapshot(); |
View IndexAsKeyBad.jsx
items.map((item, index) => { | |
return (<ItemComponent key={index} item={item} />); | |
}); |
View IndexAsKeyGood.jsx
const shortid = require('shortid'); | |
items.map((item) => { | |
return (<ItemComponent key={shortid.generate()} item={item} />); | |
}); |
View SinonExample.jsx
describe('BidListButtonComponent', () => { | |
const bidList = [{ position: { id: 1 } }]; | |
const bidListFalse = [{ position: { id: 2 } }]; | |
it('can call the toggleSaved function', () => { | |
const spy = sinon.spy(); | |
const wrapper = shallow( | |
<BidListButton | |
id={1} | |
toggleBidPosition={spy} |
OlderNewer