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

ersers

v0.0.1

Published

Slots factory

Downloads

16

Readme

Effector React Slots

A slot is a place in a component where you can insert any unknown component. It's a well-known abstraction used by frameworks such as Vue.js and Svelte.

Slots arn't present in the React. With React you can achieve this goal using props or React.Context. In large projects this is not convenient, because it generates "props hell" or smears the logic.

Using React with Effector we can achieve slot goals without the problems described above.

Try it out

Usage

Step 1

npm install --save-dev @space307/publish-wizard

# or

yarn add @space307/publish-wizard --dev

Step 2

Define constant with slots name and call createSlotFactory.

import { createSlotFactory } from '@space307/effector-react-slots';

export const SLOTS = {
  FOO: 'foo',
  BAR: 'bar',
};

export const { api, createSlot } = createSlotFactory({ slots: SLOTS });

Step 3

Create Slot component.

import React from 'react';
import { useStoreMap } from 'effector-react';

import { createSlot, SLOTS } from './slots';

const { $slot } = createSlot({ id: SLOTS.FOO });

export const FooSlot = () => {
  const Component = useStoreMap({
    store: $slot,
    fn: ({ component }) => component,
    keys: [],
  });

  return <Component />;
};

Step 4

Insert Slot component to your UI.

import React from 'react';

import { FooSlot } from './fooSlot';

export const ComponentWithSlot = () => (
  <>
    <h1>Hello, Slots!</h1>
    <FooSlot />
  </>
);

Step 5

Render something inside slot. For example, based on data from feature toogle of your app.

import { split } from 'effector';

import { $featureToggle } from './featureToggle';
import { api, SLOT } from './slots';

const MyAwesomeFeature = () => <p>Look at my horse!</p>;
const VeryAwesomeFeature = () => <p>My horse is amaizing!</p>;

split({
  source: $featureToggle,
  match: {
    awesome: (data) => msg.type === 'awesome',
    veryAwesome: (data) => msg.type === 'veryAwesome',
  },
  cases: {
    awesome: api.set.prepend(() => ({ id: SLOT.FOO, Component: MyAwesomeFeature })),
    veryAwesome: api.set.prepend(() => ({ id: SLOT.FOO, Component: VeryAwesomeFeature })),
  },
});

Try it out

TypeScript guide

Best practices for writing well-typed code.

createSlot

Props of component passed to slot can be defined as generic

const slot = createSlot<{ readonly text: string }>({ id: 'heading' });

API

createSlotFactory

Function that returns a function for creating slots and an API for working with slots.

API

createSlot

Function, takes the slot name. Returns the table containing the slot

set

remove