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

@arun413kadari/react-component-generator

v1.0.1

Published

A simple utility tool to create react component files with some boilerplate code

Downloads

7

Readme

react_component_generator

A simple utility tool to create react component files with some boilerplate code.

Note

This tool only works with the new react hooks (https://reactjs.org/docs/hooks-intro.html) and doesn't work/support class or other function based components. Hooks are the new addition or new avatar of react components and they're much easier and offer cleaner syntax to work with. So I'm restricting this tool only to hooks and I have no plans or interest to make this work with class based components.

However, if you're interested to make this work with class based components please feel free to fork this repo and contribute.

What does this tool do?

This small tool helps you in saving time by creating component files for your react applicaton. You simply need to write a small specification in YAML format describing the basic structure of each compnent such as name, state variables and handler functions. The tool, when run, will turn the specification into component files with specified boilerplate code.

Inspiration

This tools draws it's inspiration from the Open API Specification (https://swagger.io/docs/specification/about/) which helps us to design and develop most of the backend REST API.

When I started learning reactjs, I realized that it's cumbursome and routine to write/create component files by hand everytime we create a new project. I observed some of the common patterns in reactjs programming and decided to convert those patterns into a specification on the lines of Open API specification. Currently the tool is very basic in nature and I believe there is a lot of scope for evolution.

Usage

  1. Clone this repo
  2. cd to the directory
  3. Run the npm install --save command to install the dependencies
  4. Run the command followed by the specification file node generator.js <filename>

Example:

node generator.js sample_spec.yaml

Specification structure

This tool includes a sample specification file (sample_spec.yaml) to test, understand and write your own specification and below is it's structure.

components:
    -
        name: Component1
        state:
            variable_name: count1
            function_name: setcount1
            initial_value: 0
        handlers:
            - clickHandler
            - loginHandler
    
    -
        name: Component2
        state:
            variable_name: count2
            function_name: setcount2
            initial_value: 0
        handlers:
            - clickHandler
            - hoverHandler

The specification is very easy and flat to understand. All the components are stored in an array. And each component has name, state and handlers. Please follow the above structure to write your own component specification.