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

@ambilight-taro/dynamic-render-controller

v1.0.0

Published

![NPM Version](https://img.shields.io/npm/v/%40ambilight-taro%2Fdynamic-render-controller) ![NPM Downloads](https://img.shields.io/npm/dm/%40ambilight-taro%2Fdynamic-render-controller)

Readme

@ambilight-taro/dynamic-render-controller

NPM Version NPM Downloads

Installation

npm install @ambilight-taro/dynamic-render-controller

Usage

动态渲染管理器(作用就和名字一样hhh)

因为在 Taro 小程序环境下,无法动态的调用 render 将节点渲染到页面中,故而只能退而求其次,创建一个固定的渲染管理器,手动插入到页面中,用作动态 render

此组件也是组件库中AlToast.showAlPopup.show等函数式调用能力的依赖项

Basic

import { AlDynamicRenderController } from '@ambilight-taro/dynamic-render-controller'

// 所有动态渲染都将作为 children of AlDynamicRenderController 渲染到页面中
<AlDynamicRenderController />

Set controller id(recommend)

我们推荐为每一个控制器都设置全剧唯一的 controllerId

AlToast.showAlPopup.show底层调用的组件提供的safeRender函数能力,如果不设置明确id,则会默认渲染到最新创建且存在的Controller

<AlDynamicRenderController controllerId="test" />

Advance

我们可以借助 safeRender 来实现自己的函数式调用功能

  • render 渲染节点到控制器中(如出现错误则会直接抛出错误)
  • safeRender 安全渲染器(如出现错误则会进入错误队列,后续在恰当时机再次尝试)
import { safeRender } from '@ambilight-taro/dynamic-render-controller'

const showMeTheMoney = () => {
  const controller = safeRender({
    component: View,
    // targetId 可以不设置
    targetId: 'targetId',
    props: {
      children: '¥999999999'
    }
  })

  setTimeout(() => {
    controller.changeProps({
      children: '¥1000000000'
    })
  }, 1000)

  setTimeout(() => {
    controller.remove()
  }, 2000)
}

Props & Types

interface AlDynamicRenderControllerProps {
  /**
   * 控制器 id(请保持全应用唯一)
   */
  controllerId?: string
}
interface RenderDetail {
  /**
   * 渲染组件
   */
  component: React.FunctionComponent<any> | React.ComponentClass<any>
  /**
   * 渲染组件 Props
   */
  props: any
  /**
   * 目标控制器 id
   */
  targetId?: string
}

type Render = <P = any>(detail: RenderDetail) => {
  /**
   * 修改 props(使用浅层合并覆盖)
   */
  changeProps: (newProps: Partial<P>) => void
  /**
   * 删除当前渲染节点
   * @returns void
   */
  remove: () => void
}