Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactor: Avoid extra eval() when example doesn't have initialState
  • Loading branch information
sapegin committed Mar 31, 2018
1 parent d297a99 commit ae03c02
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/rsg-components/Preview/Preview.js
Expand Up @@ -70,6 +70,10 @@ export default class Preview extends Component {

// Eval the code to extract the value of the initial state
getExampleInitialState(compiledCode) {
if (compiledCode.indexOf('initialState') === -1) {
return {};
}

return this.props.evalInContext(`
var state = {}, initialState = {};
try {
Expand Down

0 comments on commit ae03c02

Please sign in to comment.