How to use the isJSXElement function from babel-types

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

91
92
93
94
95
96
97
98
99
100
ThisExpression (thisPath) {
    const parentNode = thisPath.parentPath.parentPath.parent;
    const isValid = t.isExpressionStatement(parentNode) || 
        t.isVariableDeclaration(parentNode) ||
        t.isBlockStatement(parentNode) || 
        t.isJSXElement(parentNode) || 
        t.isCallExpression(parentNode) || 
        (t.isJSXAttribute(parentNode) && !parentNode.name.name.startsWith('on'));

    if (isValid) {
fork icon64
star icon411
watch icon8

166
167
168
169
170
171
172
173
174
175

if (t.isCallExpression(p.node) && 
    t.isMemberExpression(p.node.callee) &&
    p.node.callee.object.name == 'ReactDOM' &&
    p.node.callee.property.name == 'render' &&
    t.isJSXElement(p.node.arguments[0])) {

    let el = p.node.arguments[0].openingElement;

    objArr.forEach(obj => {
fork icon1
star icon11
watch icon1

+ 3 other calls in file

70
71
72
73
74
75
76
77
78
79
JSXAttribute: path => {
    const node = path.node;
    const key = node.name.name;
    const value = getPropValue(node.value);
    const parent = path.findParent(path => {
        return types.isJSXElement(path.node)
    });
    const parentJsonNode = parent.node.__jsonNode;
    if (!parentJsonNode.props) {
        parentJsonNode.props = {};
fork icon1
star icon6
watch icon0

+ 3 other calls in file

67
68
69
70
71
72
73
74
75
76
  },
},

JSXAttribute(path) {
  const { node } = path
  const parent = path.findParent(p => types.isJSXElement(p.node))
  const parentNode = parent.node.__node
  if (!parentNode.props) {
    parentNode.props = {}
  }
fork icon1
star icon4
watch icon2

+ 3 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)