Javascript 如何在功能组件中使用流检查道具,以便我可以直接使用道具变量?
我想直接使用props作为变量,而不在它们前面添加Javascript 如何在功能组件中使用流检查道具,以便我可以直接使用道具变量?,javascript,reactjs,types,flowtype,Javascript,Reactjs,Types,Flowtype,我想直接使用props作为变量,而不在它们前面添加props对象 Smth类似:onChange={handleChange},而不是onChange={props.handleChange} type Props = { handleChange: Function, values: Object, t: Function } function RadioList(props: Props) { r
props
对象
Smth类似:onChange={handleChange}
,而不是onChange={props.handleChange}
type Props = {
handleChange: Function,
values: Object,
t: Function
}
function RadioList(props: Props) {
return (
<div className={css.radioList}>
<RadioField
isFormik
name="some_name"
label={t('some_label')}
onChange={handleChange}
className={css.listFilterRadio}
/>
</div>);
}
类型道具={
handleChange:功能,
值:对象,
t:功能
}
职能放射科医生(道具:道具){
返回(
);
}
使用
函数放射科医生({handleChange}){
返回(
);
}
使用
函数放射科医生({handleChange}){
返回(
);
}
类型道具={
handleChange:功能,
值:对象,
t:功能
}
职能放射科医生(道具:道具){
const{handleChange}=props;//解构props
const{radioList,listFilterRadio}=css;//如果您从某处获得css变量,也可以对其进行破坏
返回(
);
}
类型道具={
handleChange:功能,
值:对象,
t:功能
}
职能放射科医生(道具:道具){
const{handleChange}=props;//解构props
const{radioList,listFilterRadio}=css;//如果您从某处获得css变量,也可以对其进行破坏
返回(
);
}
function RadioList({handleChange}) {
return (
<div className={css.radioList}>
<RadioField
isFormik
name="some_name"
label={t('some_label')}
onChange={handleChange}
className={css.listFilterRadio}
/>
</div>);
}
type Props = {
handleChange: Function,
values: Object,
t: Function
}
function RadioList(props: Props) {
const { handleChange } = props; // destructuring the props
const { radioList, listFilterRadio } = css; // you can destrcture your css varible too if you are getting it from somewhere
return (
<div className={radioList}>
<RadioField
isFormik
name="some_name"
label={t('some_label')}
onChange={handleChange}
className={listFilterRadio}
/>
</div>);
}