New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

classy-react

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

classy-react - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

4

package.json
{
"name": "classy-react",
"version": "0.0.1",
"version": "0.0.2",
"main": "./src/classy-react.js",
"type": "module",
"files": [
"src/classy-react"
"src/classy-react.js"
],

@@ -9,0 +9,0 @@ "peerDependencies": {

@@ -1,8 +0,40 @@

# React + Vite
# classy-react
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- Want to use React, but tired of hooks?
- But at the same time, you super appreciate the ergonomics provided in _authoring_ hooks?
- Do you think that not being able to use hooks in classes is silly?
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
Now you can have the best both worlds, with classy-react!
```jsx
import React from 'react';
import { useState, useHooks } from './classy-react';
export default @useHooks class App {
@useState accessor count = 5;
render = () => {
return (
<>
<button onClick={() => this.count += 1}>
count is {this.count}
</button>
</>
);
}
}
```
This library is experimental, and right now only provides three exports:
- `@useHooks` - allows vanilla classes to be used as components -- like with React's own class component, the `render` function is special in that it is used to hold the template of your component.
- `@useState` - `React.useState`, but as a decorator
- `wrap` - utility for making turning your own hooks into decorators, as long as they return the tuple in the form of `[value, setter]` (like `useState` does)
Notes:
- Rules of hooks still apply (albeit now hidden~ish)
- You should never use `this.property = this.property.bind(this)` -- and React should have never recommended you do so.
- This library has no tests (for now)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc