Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-stateful-function

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-stateful-function - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

src/useDidMount.ts

2

package.json
{
"name": "react-stateful-function",
"version": "0.1.1",
"version": "0.1.2",
"description": "React Statful Function",

@@ -5,0 +5,0 @@ "main": "index.ts",

# React Stateful Function
<!-- ![npm][npmDownloads] -->
![PRsBadge] ![npm][npmLicense] ![npm][npmVersion]
##### Requires React version =< 16.8 to work
![npm][npmDownloads] ![PRsBadge] ![npm][npmLicense] ![npm][npmVersion]
### Implement react state into your function component in just One Step!
- Use funcDidMount instead of componentDidMount
- Use funcWillUnmount instead of componentWillUnmount
- Use funcDidUpdate which is easier than of componentDidUpdate
- Construct your state and update it inside any function component
- Use useDidMount instead of componentDidMount
- Use useWillUnmount instead of componentWillUnmount
- Use useDidUpdate which is easier than of componentDidUpdate
- Initialize your state and update it inside any function component
- Very simple way to change state, just like Component setState !

@@ -30,5 +30,11 @@ - No hooks background needed at all, just import and use!

import React from 'react';
import { constructState, funcDidMount, funcWillUnmount, funcDidUpdate } from 'react-stateful-function';
import {
useInitialState,
useDidMount,
useWillUnmount,
useDidUpdate
} from 'react-stateful-function';
const MyStatefulComponent = (props) => {

@@ -40,3 +46,3 @@

resetState, // <= Reset state to its initial values
} = constructState({ count: 0, toggle: false }); // <= Initialize state, just like this.state={} !
} = useInitialState({ count: 0, toggle: false }); // <= Initialize state, just like this.state={} !

@@ -47,3 +53,3 @@

funcDidMount(() => {
useDidMount(() => {

@@ -54,3 +60,3 @@ // ComponentDidMount replacement

funcWillUnmount(() => {
useWillUnmount(() => {

@@ -61,8 +67,9 @@ // ComponentWillUnmount replacement

funcDidUpdate([count], () => {
useDidUpdate([count], () => {
// ComponentDidUpdate replacement
// Comparing values' changes within renders
// Will be called if `count` value is changed
// You can make more `funcDidUpdate` with other values
// Will be called if array values are changed
// You can make more than one `useDidUpdate` hooks
// Or Add new variables inside `values` array to call same action

@@ -69,0 +76,0 @@ });

@@ -1,4 +0,4 @@

export * from './constructState';
export * from './funcDidMount';
export * from './funcWillUnmount';
export * from './functDidUpdate';
export * from './useInitialState';
export * from './useDidMount';
export * from './useWillUnmount';
export * from './usetDidUpdate';

Sorry, the diff of this file is not supported yet

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