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 🙏

© 2024 – Pkg Stats / Ryan Hefner

inspectr

v0.0.6

Published

Inspect React components from the command line

Downloads

5

Readme

inspectr

A CLI for inspecting React components to reveal propTypes and defaultProps values.

##Installation

npm install -g inspectr

##Usage inspectr takes two arguments

inspectr <module> [component] 

inspectr takes the -f option to specify a specific file path to inspect

inspectr <module-path> [component] -f 

###module The module argument is the name of the module to search for a React Component to inspect or if you pass -f the relative file path to a module to inspect.

###component The component argument is optional if you are inspecting default exports, however to inspect named exports, you need to pass the name of the export here.

##Examples ###Inspecting node modules Assuming you want to inspect react-router and are in your project root, run -

inspectr react-router

┌──────────────────┬────────────────────────┬────────────────────────────────────────────┐
│ Property         │ Type                   │ Default Value                              │
├──────────────────┼────────────────────────┼────────────────────────────────────────────┤
│ history          │ React.PropTypes.object │ N/A                                        │
├──────────────────┼────────────────────────┼────────────────────────────────────────────┤
│ children         │ React.PropTypes.object │ N/A                                        │
├──────────────────┼────────────────────────┼────────────────────────────────────────────┤
│ routes           │ React.PropTypes.object │ N/A                                        │
├──────────────────┼────────────────────────┼────────────────────────────────────────────┤
│ RoutingContext   │ React.PropTypes.func   │ function RoutingContext() {                │
│                  │                        │     _classCallCheck(this, RoutingContext); │
│                  │                        │                                            │
│                  │                        │     _Component.apply(this, arguments);     │
│                  │                        │   }                                        │
├──────────────────┼────────────────────────┼────────────────────────────────────────────┤
│ createElement    │ React.PropTypes.func   │ N/A                                        │
├──────────────────┼────────────────────────┼────────────────────────────────────────────┤
│ onError          │ React.PropTypes.func   │ N/A                                        │
├──────────────────┼────────────────────────┼────────────────────────────────────────────┤
│ onUpdate         │ React.PropTypes.func   │ N/A                                        │
├──────────────────┼────────────────────────┼────────────────────────────────────────────┤
│ parseQueryString │ React.PropTypes.func   │ N/A                                        │
├──────────────────┼────────────────────────┼────────────────────────────────────────────┤
│ stringifyQuery   │ React.PropTypes.func   │ N/A                                        │
└──────────────────┴────────────────────────┴────────────────────────────────────────────┘

If you want to inspect the Link component, you could run

inspectr react-router Link

┌───────────────────┬────────────────────────┬───────────────┐
│ Property          │ Type                   │ Default Value │
├───────────────────┼────────────────────────┼───────────────┤
│ to                │ React.PropTypes.string │ N/A           │
├───────────────────┼────────────────────────┼───────────────┤
│ query             │ React.PropTypes.object │ N/A           │
├───────────────────┼────────────────────────┼───────────────┤
│ hash              │ React.PropTypes.string │ N/A           │
├───────────────────┼────────────────────────┼───────────────┤
│ state             │ React.PropTypes.object │ N/A           │
├───────────────────┼────────────────────────┼───────────────┤
│ activeStyle       │ React.PropTypes.object │ N/A           │
├───────────────────┼────────────────────────┼───────────────┤
│ activeClassName   │ React.PropTypes.string │ N/A           │
├───────────────────┼────────────────────────┼───────────────┤
│ onlyActiveOnIndex │ React.PropTypes.bool   │ N/A           │
├───────────────────┼────────────────────────┼───────────────┤
│ onClick           │ React.PropTypes.func   │ N/A           │
└───────────────────┴────────────────────────┴───────────────┘

###Inspecting file paths To inspect your own components you can use file paths with the -f option.

inspectr app/javascripts/components/button.jsx -f

##Limitations Currently inspectr can only determine PropTypes through evaluting the checkType returned from the React PropTypes definition. So this means it supports the following propTypes-

  • React.PropTypes.array
  • React.PropTypes.bool
  • React.PropTypes.func
  • React.PropTypes.number
  • React.PropTypes.object
  • React.PropTypes.string
  • React.PropTypes.any