How to use the isJSXIdentifier function from @babel/types

Find comprehensive JavaScript @babel/types.isJSXIdentifier code examples handpicked from public code repositorys.

204
205
206
207
208
209
210
211
212
213
    );
  }
} else if (t.isJSXMemberExpression(node.name)) {
  // <RecyclerView.Cell /> or <Context.Provider>
  const { object, property } = node.name;
  if (t.isJSXIdentifier(object) && t.isJSXIdentifier(property)) {
    if (property.name === 'Provider') {
      // <Context.Provider>
      const valueAttribute = node.attributes.find(a =>
        t.isJSXIdentifier(a.name, { name: 'value' }),
fork icon32
star icon66
watch icon12

+ 45 other calls in file

192
193
194
195
196
197
198
199
200
201
const { object, property } = node.name;
if (t.isJSXIdentifier(object) && t.isJSXIdentifier(property)) {
  if (property.name === 'Provider') {
    // <Context.Provider>
    const valueAttribute = node.attributes.find(a =>
      t.isJSXIdentifier(a.name, { name: 'value' }),
    );
    const contextInitValue = valueAttribute && valueAttribute.value.expression;
    const contextItem = {
      contextInitValue,
fork icon664
star icon11
watch icon1

+ 35 other calls in file

186
187
188
189
190
191
192
193
194
195
  [adapter.forIndex]: t.stringLiteral(renamedIndex.name),
};

if (adapter.needTransformKey && t.isJSXElement(returnElPath.node)) {
  const attributes = returnElPath.node.openingElement.attributes;
  const keyIndex = findIndex(attributes, attr => t.isJSXIdentifier(attr.name, { name: 'key' }));
  if (keyIndex > -1) {
    listAttr.key = attributes[keyIndex].value;
    attributes.splice(keyIndex, 1);
  } else {
fork icon663
star icon11
watch icon1

+ 13 other calls in file

13
14
15
16
17
18
19
20
21
22
let rootName = name && name.name;

try {
  // 针对 Card.Content 这种子组件
  if (t.isJSXMemberExpression(name)) {
    if (t.isJSXIdentifier(name.object) && t.isJSXIdentifier(name.property)) {
      componentName = `${name.object.name}.${name.property.name}`;
      rootName = name.object.name;
    }
  // 针对 React 组件
fork icon59
star icon0
watch icon0

+ 3 other calls in file

63
64
65
66
67
68
69
70
71
72

// Only inspect elements that are `<I18N.Ref>`.
if (types.isJSXMemberExpression(name)) {
  const { object, property } = name;
  if (
    types.isJSXIdentifier(object, { name: 'I18N' }) &&
    types.isJSXIdentifier(property, { name: 'Ref' })
  ) {
    const i18nId = getPropStringFromI18NJSX(attributes, 'id');
    if (i18nId) {
fork icon5
star icon24
watch icon13

+ 19 other calls in file

88
89
90
91
92
93
94
95
96
97
JSXElement(nodePath) {
  const { node } = nodePath;
  // update Shell attribute
  if (
    t.isJSXOpeningElement(node.openingElement) &&
    t.isJSXIdentifier(node.openingElement.name, { name: 'Shell' })
  ) {
    SHELL_ATTRIBUTE.forEach((attribute) => {
      const value = layoutConfig[attribute.property] || attribute.value;
      const nodeValue = attribute.type === 'stringLiteral' ? t.stringLiteral(value) : t.jsxExpressionContainer(t[attribute.type](value));
fork icon3
star icon3
watch icon11

+ 11 other calls in file

64
65
66
67
68
69
70
71
72
73
    name = node.name.name;
    state.isLegacyRef.value = false;
  }
} else if (state.isLegacyRef.value === false || state.syntacticPlaceholders) {
  return;
} else if (t.isIdentifier(node) || t.isJSXIdentifier(node)) {
  name = node.name;
  state.isLegacyRef.value = true;
} else if (t.isStringLiteral(node)) {
  name = node.value;
fork icon0
star icon1
watch icon1

+ 4 other calls in file

260
261
262
263
264
265
266
267
268
269
const canvasExports = {};

for (let i = 0; i < ast.children.length; i += 1) {
  const child = ast.children[i];

  if (t.isJSXElement(child) && t.isJSXIdentifier(child.openingElement.name) && child.openingElement.name.name === 'Story') {
    const storyExport = genStoryExport(child, context);
    const {
      code
    } = generate(child, {}); // @ts-ignore
fork icon1
star icon2
watch icon1

434
435
436
437
438
439
440
441
442

let attribs = [];
const extracted = Object.create(null);

for (const attr of openingPath.get("attributes")) {
  if (attr.isJSXAttribute() && t.isJSXIdentifier(attr.node.name)) {
    const {
      name
    } = attr.node.name;
fork icon0
star icon0
watch icon1

+ 17 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 (20936 examples)