
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
A React state management library Based on Hooks, it begins as a fork of stamen
Relax is opinionated, it has these benefits:
connect、mapState
yarn add relax-ts
import React from 'react'
import ReactDOM from 'react-dom'
import { createStore } from '../../src'
const { useSelector, dispatch, Provider } = createStore({
state: {
count: 0,
},
reducers: {
increment(state) {
state.count++
},
decrement(state) {
state.count--
},
},
effects: {
async asyncIncrement() {
await new Promise(resolve => {
setTimeout(() => {
resolve()
}, 1000)
})
dispatch('increment')
},
},
})
const Counter = () => {
const count = useSelector(S => S.count)
return (
<div>
<span>{count}</span>
<div>
<button onClick={() => dispatch('decrement')}>-</button>
<button onClick={() => dispatch('increment')}>+</button>
<button onClick={() => dispatch('asyncIncrement')}>async+</button>
</div>
</div>
)
}
function App() {
return (
<Provider initialState={{ count: 10 }}>
<Counter />
</Provider>
)
}
ReactDOM.render(<App />, document.getElementById('root'))
Check on CodeSandbox: Basic | Async
Overview
const someStore = createStore({
state: {},
reducers: {},
affects: {},
})
const { useSelector, dispatch } = someStore
The initial state of a Store.
const someStore = createStore({
state: {
count: 0,
},
})
Two type action in Relax: reducers and effects, you can update state in reducers only.
const someStore = createStore({
reducers: {
increment(state, payload) {
state.count += payload
},
},
})
You can handle async actions in effects. Such as Fecthing data via nenwork
const someStore = createStore({
effects: {
async asyncIncrement() {
await new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, 1000)
})
someStore.dispatch('increment')
},
},
})
Get state in view using react hooks api.
const App = () => {
const { useSelector } = counterStore
const count = useSelector(S => S.count)
return <span>{count}</span>
}
Dispatch an Action to update state.
const App = () => {
const { useSelector, dispatch } = counterStore
const count = useStore(S => S.count)
return (
<div>
<span>{count}</span>
<button onClick={() => dispatch('decrement')}>-</button>
<button onClick={() => dispatch('increment')}>+</button>
</div>
)
}
FAQs
Unknown package
The npm package relax-ts receives a total of 0 weekly downloads. As such, relax-ts popularity was classified as not popular.
We found that relax-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.