也许我知道如何使用React Admin从TextInput字段中的React Rrule Generator中获取onChange()值。
代码:
输出示例:
<RRuleGenerator
onChange={(recurrences) => console.log(`${recurrences}`)}
config={{
repeat: ['Monthly', 'Weekly'],
yearly: 'on the',
monthly: 'on',
end: ['Never', 'On date'],
weekStartsOnSunday: true,
hideError: true,
}}
/>
<TextInput label="Recurrences" source="recurrences" />
我使用的react-rrule-generator:https://github.com/fafruch/react-rrule-generator
const React, { useState, Fragment } from 'react'
const x = () => {
const [state, setState] = useEffect('')
return (
<Fragment>
<RRuleGenerator
onChange={val => setState(val)}
config={{
repeat: ['Monthly', 'Weekly'],
yearly: 'on the',
monthly: 'on',
end: ['Never', 'On date'],
weekStartsOnSunday: true,
hideError: true,
}}
/>
<TextInput label="Recurrences" source="recurrences" value={state} />
</Fragment>
)
}
使用这样的状态对象