Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@bramblex/state-model
Advanced tools
为 React 设计的简易模型,帮助 React 用户进行模型驱动设计。
使用 npm 安装
npm install --save @bramblex/state-model
使用 yarn 安装
yarn add @bramblex/state-model
import {
StateModel,
useModel,
useLocalModel,
useModelProvider,
useModelContext
} from '@brambles/state-model'
class Counter extends StateModel<{ count: number }> {
constructor() {
super({ count: 0 })
}
increase() {
this.setState({ count: this.state.count + 1 });
}
decrease() {
this.setState({ count: this.state.count - 1 });
}
}
const counter = new Counter();
function App() {
useModel(counter);
return (
<div>
<div>{model.state.count}</div>
<div>
<button onClick={() => counter.increase()}>+</button>
<button onClick={() => counter.decrease()}>-</button>
</div>
</div>
);
}
function App() {
const counter = useLocalModel(() => new Counter(), []);
return (
<div>
<div>{model.state.count}</div>
<div>
<button onClick={() => counter.increase()}>+</button>
<button onClick={() => counter.decrease()}>-</button>
</div>
</div>
);
}
function Increase() {
const counter = useModelContext(Counter);
return <button onClick={() => counter.increase()}>+</button>
}
function Decrease() {
const counter = useModelContext(Counter);
return <button onClick={() => counter.decrease()}>-</button>
}
function Count() {
const counter = useModelContext(Counter);
useModel(counter);
return <div>{model.state.count}</div>
}
function App() {
const counter = useLocalModel(() => new Counter(), []);
// 等效于
// const counter = useModel(useMemo(() => new Counter(), []));
const Provider = useModelProvider(Counter);
return (
<Provider value={counter}>
<div>
<Count />
<div>
<Increase />
<Decrease />
</div>
</div>
</Provider>
);
}
FAQs
Simple model
We found that @bramblex/state-model 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.