Security News
Supply Chain Attack Detected in @solana/web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
stated-form-bean
Advanced tools
React Form Binding via StatedBean
# yarn
yarn add stated-bean yup stated-form-bean
yarn add @types/yup -D
# npm
npm i stated-bean yup stated-form-bean
npm i @types/yup -D
import { StatedBean, Stated } from 'stated-bean';
import { Valid, FormModel } from 'stated-form-bean';
import * as yup from 'yup';
export interface User {
name: string;
age: number;
}
@StatedBean()
export class UserModel extends FormModel<UserModel> {
@Stated()
@Valid(
yup.object().shape({
name: yup.string().required(),
age: yup
.number()
.min(10)
.max(99)
.required(),
}),
{ validOnChange: false },
)
user: Partial<User> = { age: 15 };
setUser(u: Partial<User>) {
this.user = {
...this.user,
...u,
};
}
}
import { useStatedBean } from 'stated-bean';
import { UserModel } from './UserModel';
import * as React from 'react';
export const UserForm = () => {
const model = useStatedBean(UserModel);
const { errors } = model.getFormField('user');
const handleSubmit = React.useCallback(
async e => {
e.preventDefault();
console.log(model);
const valid = await model.validate('user');
if (valid) {
alert('valid success');
}
},
[model],
);
return (
<div>
<form>
<div>
<label>UserName:</label>
<input
type="text"
value={model.user.name || ''}
onChange={e => model.setUser({ name: e.target.value })}
/>
<span>{errors && errors.name}</span>
</div>
<div>
<label>Age:</label>
<input
type="number"
min={10}
max={99}
value={model.user.age}
onChange={e => model.setUser({ age: Number(e.target.value) })}
/>
<span>{errors && errors.age}</span>
</div>
<button type="submit" onClick={handleSubmit}>
Submit
</button>
</form>
</div>
);
};
const app = new StatedBeanApplication();
app.setInterceptors(new FormValidateInterceptor());
const App = () => {
return (
<StatedBeanProvider application={app} types={[]}>
<UserForm />
</StatedBeanProvider>
);
};
FAQs
React Form Binding via StatedBean
We found that stated-form-bean demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.