npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ffsm/as-array

v0.0.1

Published

A lightweight React utility component that allows passing the same props to multiple children at once, simplifying component composition and reducing repetitive code.

Downloads

10

Readme

@ffsm/as-array

A lightweight React utility component that enables you to pass the same props to multiple children at once.

Installation

# Using npm
npm install @ffsm/as-array

# Using yarn
yarn add @ffsm/as-array

# Using pnpm
pnpm add @ffsm/as-array

Features

  • Pass common props to all children with a clean syntax
  • Works with any valid React element
  • Preserves text nodes and other non-element children
  • Typescript support
  • Zero dependencies

Usage

Basic Example

import { AsArray } from '@ffsm/as-array';

function App() {
  return (
    <AsArray className="btn" disabled={true}>
      <button>Save</button>
      <button>Cancel</button>
      <button>Reset</button>
    </AsArray>
  );
}

The code above will render three buttons, each with the className "btn" and the disabled attribute set to true.

Mixed Content

import { AsArray } from '@ffsm/as-array';

function App() {
  return (
    <AsArray data-testid="test-element">
      <div>First element</div>
      Some text between elements
      <div>Last element</div>
    </AsArray>
  );
}

The text node will be preserved while both div elements will receive the data-testid attribute.

Conditional Rendering

import { AsArray } from '@ffsm/as-array';

function Form({ isReadOnly }) {
  return (
    <AsArray disabled={isReadOnly}>
      <input type="text" name="name" />
      <input type="email" name="email" />
      <button type="submit">Submit</button>
    </AsArray>
  );
}

API Reference

AsArray

The main component exposed by this package.

Props

Any props passed to AsArray will be forwarded to each child element. The component itself doesn't have any specific props aside from children.

TypeScript Support

The package includes TypeScript definitions. The AsArray component is fully typed:

import { AsArray } from '@ffsm/as-array';

function TypedExample() {
  return (
    <AsArray className="container" aria-label="group">
      <div>TypeScript supported!</div>
    </AsArray>
  );
}

How It Works

AsArray uses React's Children.toArray() to normalize and map through its children. For each child:

  1. If the child is not a valid React element (like a text node), it's wrapped in a Fragment with a key
  2. If the child is a valid React element, it's cloned using cloneElement with merged props from both the original child and the AsArray component

Browser Support

This package targets ES modules and works in all modern browsers that support React.

License

MIT