Reproduction link
https://stackblitz.com/edit/react-vhhuml?file=src%2Findex.js,src%2FApp.js
Steps to reproduce
- Type anything in input
- Watch the changes in the console
What is expected?
I'm writing a customized form control. I found that we are using the FormItemInputContext
to share the context from the Form.Item
to the children, so I want to use the FormItemInputContext
to get the contextStatus
, hasFeedback
, feedbackIcon
,... but it's always an empty object. So how to use it in a customized form control?
What is actually happening?
The context is always an empty object
| Environment | Info |
| ------------ | ------------ |
| antd | 4.21.0 |
| React | 17.0.2 |
| System | Windows |
| Browser | Chrome |
2条答案
按热度按时间hs1rzwqc1#
same issue here
need help
lbsnaicq2#
import { FormItemInputContext } from 'antd/es/form/context';
...
const context = useContext(FormItemInputContext);
import source should be 'antd/es/form/context'