How to use the JSXExpressionContainer function from babel-types

Find comprehensive JavaScript babel-types.JSXExpressionContainer code examples handpicked from public code repositorys.

50
51
52
53
54
55
56
57
58
59
60
 function createConditionNode (condition,jsxNode){
  let conditionNode = jsxNode;
  if (condition && condition.type === 'JSExpression' && condition.value){  
    let ast = parse(`Boolean(${condition.value})`);
    let left = ast.program.body[0].expression;
    conditionNode = t.JSXExpressionContainer(t.LogicalExpression('&&', left,jsxNode));
  }


  return conditionNode;
}
fork icon0
star icon1
watch icon0

+ 29 other calls in file

49
50
51
52
53
54
55
56
57
58
  // console.log('attrs:'+code);
  // 表达式转化
  let ast = util.parseCode(code);
  let program = ast.program;
  if (program.body && program.body.length>0){
    return t.JSXExpressionContainer(program.body[0].expression);
  }else{
    return t.JSXExpressionContainer(t.stringLiteral(code));
  }
}
fork icon0
star icon1
watch icon0

+ 7 other calls in file

Other functions in babel-types

Sorted by popularity

function icon

babel-types.identifier is the most popular function in babel-types (4076 examples)