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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-visible-control

v1.1.9

Published

A wrapper for controlling components rendering in declarative way

Readme

React Visible Control

CircleCI codecov npm version

Control the rendering or non-rendering of components in simple way.

Works for React & React Native.

WARNING!!!, please make sure you know what you are doing !

this lib use React Context API, please make sure the shouldComponentUpdate method works correct in your project

install

npm i -S react-visible-control

sample application

Here is a sample application based on react-visible-control

Basic usage as following

import React, { Component } from 'react';
import { Failback, VisibleContext, VisibleControl } from 'react-visible-control';


const visibleData = { "home": true, "page1": true, "page2": false }

export default class Test extends Component {
  render() {
    return (
      <VisibleContext data={visibleData}>
        <div>
          <VisibleControl visibleKey={"home"}>
            <p>home</p>
          </VisibleControl>
          <VisibleControl visibleKey={"page1"}>
            <p>page1</p>
          </VisibleControl>
          <VisibleControl visibleKey={"page2"}>
            <p>page2</p>
            <Failback><p>you cant access page2, but you could show a failback thing here</p></Failback>
          </VisibleControl>
          <VisibleControl visibleKey={"page3"}>
            <p>page3</p>
          </VisibleControl>
        </div>
      </VisibleContext>
    );
  }
}

Render Result:

<div>
  <p>
    home
  </p>
  <p>
    page1
  </p>
  <p>
    you cant access page2, but you could show a failback thing here
  </p>
</div>

custom usage

in this demo, without permission, react will not render child component


// mock user data
const users = [
  {
    "name": "Theo Sun",
    "permissions": [
      "user_read",
      "user_write",
      "user_update",
      "user_delete"
    ],
    "role": "user_manager"
  },
  {
    "name": "Cherry Xu",
    "permissions": ["user_read"],
    "role": "user_viewer"
  }

];

// custome Control
const userHavePermission = per => data => data.permissions && data.permissions.indexOf(per) >= 0

export const UserReadPermission   = createVisibleControl(userHavePermission("user_read"));
export const UserWritePermission  = createVisibleControl(userHavePermission("user_write"));
export const UserDeletePermission = createVisibleControl(userHavePermission("user_delete"));
export const UserUpdatePermission = createVisibleControl(userHavePermission("user_update"));

// app view
class App extends Component {

  constructor(props) {
    super(props);
    this.state = {
      "counter": 0,
      "visibleData": {}
    };
  }

  render() {
    return (
      <VisibleContext data={this.state.visibleData}>
        <button onClick={() => {
          this.setState({ "visibleData": users[this.state.counter % users.length] });
          this.setState({ "counter": this.state.counter + 1 });
        }} >
          change user</button>
        <div className="App">
          <UserDeletePermission><p>You have User Delete Permission</p></UserDeletePermission>
          <UserWritePermission><p>You have User Write Permission</p></UserWritePermission>
          <UserReadPermission><p>You have User Read Permission</p></UserReadPermission>
          <UserUpdatePermission><p>You have User Update Permission</p></UserUpdatePermission>
        </div>
      </VisibleContext>
    );
  }
}

License

MIT