Skip to content

Commit

Permalink
fix: error handling for generating function components
Browse files Browse the repository at this point in the history
  • Loading branch information
yawetse committed May 12, 2021
1 parent 1e8e404 commit 21fe78a
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,18 +671,24 @@ export function getReactFunctionComponent(
const self = this || {};
return function ${options.name || "Anonymous"}(props){
${functionBody}
if(typeof exposeprops==='undefined' || exposeprops){
reactComponent.props = Object.assign({},props,typeof exposeprops==='undefined'?{}:exposeprops);
if(typeof exposeprops!=='undefined') reactComponent.__functionargs = Object.keys(exposeprops);
} else{
reactComponent.props = props;
}
if(!props?.children) {
// delete props.children;
try {
${functionBody}
if(typeof exposeprops==='undefined' || exposeprops){
reactComponent.props = Object.assign({},props,typeof exposeprops==='undefined'?{}:exposeprops);
if(typeof exposeprops!=='undefined') reactComponent.__functionargs = Object.keys(exposeprops);
} else{
reactComponent.props = props;
}
if(!props?.children) {
// delete props.children;
}
const context = ${options.bind ? "Object.assign(self,this||{})" : "this"};
return getReactElementFromJSONX.call(context, reactComponent);
} catch(e){
if(self.debug) return e.toString()
else throw e
}
const context = ${options.bind ? "Object.assign(self,this||{})" : "this"};
return getReactElementFromJSONX.call(context, reactComponent);
}
`
);
Expand Down

0 comments on commit 21fe78a

Please sign in to comment.