Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
Prevent a crash when working with symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Agbonon committed Mar 24, 2016
1 parent 3926ff8 commit 0891c4b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion demo/src/js/DemoApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class DemoApp extends React.Component {
<Button onClick={this.props.addFunction} style={styles.button}>
Add Function
</Button>
<Button onClick={this.props.addSymbol} style={styles.button}>
Add Symbol
</Button>
</div>
</div>
<div style={styles.links}>
Expand Down Expand Up @@ -155,6 +158,7 @@ export default connect(
type: 'HUGE_PAYLOAD',
payload: Array.from({ length: 10000 }).map((_, i) => i)
}),
addFunction: () => ({ type: 'ADD_FUNCTION' })
addFunction: () => ({ type: 'ADD_FUNCTION' }),
addSymbol: () => ({ type: 'ADD_SYMBOL' })
}
)(DemoApp);
4 changes: 3 additions & 1 deletion demo/src/js/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,7 @@ export default combineReducers({
str => str + '!'
) : state,
addFunction: (state=null, action) => action.type === 'ADD_FUNCTION' ?
{ f: FUNC } : state
{ f: FUNC } : state,
addSymbol: (state=null, action) => action.type === 'ADD_SYMBOL' ?
{ s: Symbol('symbol') } : state
});
2 changes: 2 additions & 0 deletions src/ActionPreview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ function getItemString(createTheme, type, data) {
return 'fn';
} else if (typeof val === 'string') {
return `"${val.substr(0, 10) + (val.length > 10 ? '…' : '')}"`
} else if (typeof val === 'symbol') {
return 'symbol'
} else {
return val;
}
Expand Down
2 changes: 1 addition & 1 deletion src/JSONDiff.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import JSONTree from '@alexkuz/react-json-tree';
import themeable from './themeable';
import stringify from 'javascript-stringify';
import { stringify } from 'jsan';

function stringifyAndShrink(val) {
const str = stringify(val);
Expand Down

0 comments on commit 0891c4b

Please sign in to comment.