Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
redux-form-material-ui
Advanced tools
redux-form-material-ui
is a set of
wrappers to facilitate the use of
material-uibeta
components with
redux-form
.
Latest version is supported by only for material-ui beta.
Using npm:
$ npm install --save redux-form-material-ui@next
Using npm:
$ yarn add redux-form-material-ui@next
Rather than import your component class from material-ui
, import it from redux-form-material-ui
and then pass the component class directly to the component
prop of Field
.
import { reduxForm, Field } from 'redux-form'
import MenuItem from 'material-ui/MenuItem'
import { RadioButton } from 'material-ui/RadioButton'
import {
Checkbox,
RadioGroup,
Select,
TextField,
Switch,
} from 'redux-form-material-ui'
class MyForm extends Component {
render() {
return (
<form>
<Field name="username" component={TextField} placeholder="Street"/>
<Field name="plan" component={Select} placeholder="Select a plan">
<MenuItem value="monthly">Monthly</MenuItem>
<MenuItem value="yearly">Yearly</MenuItem>
<MenuItem value="lifetime">Lifetime</MenuItem>
</Field>
<FormControlLabel control={<Field name="agreeToTerms" component={Checkbox} /> } label="Agree to terms?" />
<FormControlLabel control={<Field name="receiveEmails" component={Switch} /> } label="Please spam me!" />
<Field name="bestFramework" component={RadioGroup}>
<RadioButton value="react" label="React"/>
<RadioButton value="angular" label="Angular"/>
<RadioButton value="ember" label="Ember"/>
</Field>
</form>
)
}
}
// Decorate with redux-form
MyForm = reduxForm({
form: 'myForm'
})(MyForm)
export default MyForm
Because of the strict "controlled component" nature of redux-form
,
some of the Material UI functionality related to defaulting of values has been disabled
e.g. defaultValue
, defaultDate
, defaultTime
, defaultToggled
, defaultChecked
, etc.
If you need a field to be initialized to a certain state, you should use the initialValues
API of redux-form
.
getRenderedComponent()
Returns a reference to the Material UI component that has been rendered. This is useful for
calling instance methods on the Material UI components. For example, if you wanted to focus on
the username
element when your form mounts, you could do:
componentWillMount() {
this.refs.firstField // the Field
.getRenderedComponent() // on Field, returns ReduxFormMaterialUITextField
.getRenderedComponent() // on ReduxFormMaterialUITextField, returns TextField
.focus() // on TextField
}
as long as you specified a ref
and withRef
on your Field
component.
render() {
return (
<form>
...
<Field name="username" component={TextField} withRef ref="firstField"/>
...
</form>
)
}
FAQs
An adapter between Redux Form and Material UI components
The npm package redux-form-material-ui receives a total of 5,533 weekly downloads. As such, redux-form-material-ui popularity was classified as popular.
We found that redux-form-material-ui 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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.