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

@voitanos/spfx-mod-hookmeup

v1.11.0

Published

Convert the Microsoft 365 SPFx Yeoman Generator template for React components from a class component to a functional component.

Downloads

1,033

Readme

Microsoft 365 SPFx Yeoman Generator Mod - SPFx Mod Hook Me Up!

Convert React Class Components to Functional Components

This NPX command that will modify the SharePoint Framework (SPFx) React web part template to use React functional components (ie: React Hooks).

The Microsoft 365 SPFx Yeoman Generator is used to create new SPFx projects & various component types, including web parts, extensions, Adaptive Card Extensions (ACEs), and library components.

When creating an SPFx web part, developers can choose from a few different options, including using React as the desired web framework. The SPFx generator creates a single React component, but it's a class component. The React team introduced React Hooks in React v16.8. The React team considers class components as legacy & not recommended.

However, even though the SPFx has supported React v16.8+ since SPFx v1.9.1, the SPFx generator still creates a class component, meaning developers must manually convert every new React web part after adding it to their project.

Learn how to convert a new SPFx React component in a web part from this article: How to use React Hooks with the SharePoint Framework (SPFx) & associated video YouTube.

But, using this "SPFx Mod HookMeUp" using this NPX command, you can now update your SPFx template to always create a React functional component!

Usage

After installing the Microsoft 365 SPFx Yeoman Generator, run the following command:

npx @voitanos/spfx-mod-hookmeup

This will replace the default template file that contains a class component in the generator with one that will create a function component every time you run the generator!

NOTE: You'll need to re-run the Hook Me Up mod if you update, upgrade, or reinstall the Microsoft 365 SPFx Yeoman Generator.

Supported Versions

This mod will work with any Microsoft 365 SPFx Yeoman Generator version from v1.9.1 to the latest release. The latest version will always work with the @latest version of the generator. If you're using an older version of the generator, make sure you use the matching version of the mod.

For example, if you're currently using SPFx v1.9.1, use the same version of the mod:

npx @voitanos/[email protected]