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

Function countChars

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

Source from the content-addressed store, hash-verified

424}
425
426function countChars(element: ReactNode) {
427 if (typeof element === 'string') {
428 return element.length;
429 } else if (Array.isArray(element)) {
430 return element.reduce((p, i) => p + countChars(i), 0);
431 } else if (element && typeof element === 'object' && 'props' in element && element.props) {
432 return countChars((element.props as any).children);
433 }
434 return 0;
435}
436
437function renderProp(name: string, value: any, control?: PropControl, indent = '') {
438 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