How to use the isJSXExpressionContainer function from babel-types
Find comprehensive JavaScript babel-types.isJSXExpressionContainer code examples handpicked from public code repositorys.
GitHub: kalohq/recon
209 210 211 212 213 214 215 216 217 218
} : { name: attr.name.name, // TODO: see if we can find union of possible values. Eg. color = someVar ? 'green' : 'red' // TODO: for simple identifier types we could sometimes resolve to component prop types type: T.isJSXExpressionContainer(attr.value) ? resolveType(attr.value.expression) : resolveType(attr.value), } ),
9
299
18
+ 5 other calls in file
GitHub: ygmpkk/anu
46 47 48 49 50 51 52 53 54 55
getAnu(state) { return state.file.opts.anu; }, isLoopMap(astPath) { if ( t.isJSXExpressionContainer(astPath.parentPath) || t.isConditionalExpression(astPath.parentPath) ) { var callee = astPath.node.callee; return (
330
0
1
21 22 23 24 25 26 27 28 29 30
for (let i = 0; i < attributes.length; i++) { const attr = attributes[i]; if (t.isJSXAttribute(attr)) { const name = PathUtils.getJSXAttributeName(attr); const expr = t.isJSXExpressionContainer(attr.value) ? attr.value.expression : attr.value; if (name === 'class' || name === 'className') { classExpressions.push(expr); attributes.splice(i--, 1); }
7
0
2
+ 5 other calls in file
44 45 46 47 48 49 50 51 52 53
const subAttr = attributes[i]; if (t.isJSXAttribute(subAttr)) { const subAttrName = PathUtils.getJSXAttributeName(subAttr); if (subAttrName.indexOf('style-') === 0) { const key = camelCaseHyphens(subAttrName.slice('style-'.length)); const value = t.isJSXExpressionContainer(subAttr.value) ? subAttr.value.expression : subAttr.value; subValues.push(t.objectProperty(t.stringLiteral(key), value)); attributes.splice(i--, 1); } }
7
0
2
+ 5 other calls in file
8 9 10 11 12 13 14 15 16 17
let classNameAttr = classDirAttrs.find(prop => { return prop.name.name == 'className'; }); let classNameValue; if (classNameAttr && t.isJSXExpressionContainer(classNameAttr.value)) { classNameValue = classNameAttr.value.expression; } else if (classNameAttr && t.isStringLiteral(classNameAttr.value)) { classNameValue = classNameAttr.value; }
0
4
0
babel-types.identifier is the most popular function in babel-types (4076 examples)