How to use the isValidElement function from react

Find comprehensive JavaScript react.isValidElement code examples handpicked from public code repositorys.

11
12
13
14
15
16
17
18
19
20
        return children;
}

// Insert separators
var separator = props.separator;
var separatorIsElement = React.isValidElement(separator);
var items = [children.shift()];
children.forEach(function(item, index) {
        if (separatorIsElement) {
                var key = 'separator-' + (item.key || index);
fork icon3
star icon48
watch icon3

42
43
44
45
46
47
48
    }
}

function isRenderable(arg) {
    var type = typeof arg;
    return type === 'string' || type === 'number' || React.isValidElement(arg);
}
fork icon0
star icon8
watch icon1

1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
function isDOMComponent(inst) {
  return !!(inst && inst.nodeType === ELEMENT_NODE && inst.tagName);
}


function isDOMComponentElement(inst) {
  return !!(inst && React.isValidElement(inst) && !!inst.tagName);
}


function isCompositeComponent(inst) {
  if (isDOMComponent(inst)) {
fork icon0
star icon0
watch icon1

+ 2 other calls in file

205
206
207
208
209
210
211
212
213
214
  }, []);
  return [aniRef];
};

var isValidComponent = function isValidComponent(Component) {
  return React.isValidElement(Component) || jsutils.isFunc(Component);
};

var renderFromType = function renderFromType(Element, props, Wrapper) {
  return isValidComponent(Element) ? jsutils.isFunc(Element) ? React__default.createElement(Element, props) : Element : jsutils.isArr(Element) ? Element : Wrapper ? React__default.createElement(Wrapper, props, Element) : Element;
fork icon0
star icon0
watch icon0