MCPcopy Create free account
hub / github.com/adobe/react-spectrum / countChars

Function countChars

packages/dev/s2-docs/src/VisualExampleClient.tsx:421–430  ·  view source on GitHub ↗
(element: ReactNode)

Source from the content-addressed store, hash-verified

419}
420
421function countChars(element: ReactNode) {
422 if (typeof element === 'string') {
423 return element.length;
424 } else if (Array.isArray(element)) {
425 return element.reduce((p, i) => p + countChars(i), 0);
426 } else if (element && typeof element === 'object' && 'props' in element && element.props) {
427 return countChars((element.props as any).children);
428 }
429 return 0;
430}
431
432function renderProp(name: string, value: any, control?: PropControl, indent = '') {
433 if (value === control?.default) {

Callers 3

CodePropsFunction · 0.85
renderElementFunction · 0.85
renderValueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected