admin管理员组文章数量:1278760
I’m using Fluent UI to build a Pivot component with a form inside, with the goal of having multiple fields across different pivots, similar to the example in this image: tabbed form
However, I'm encountering an issue where the form fields get reset every time the pivot is changed. This is unexpected behavior, as I want the form fields to retain their values even when switching between tabs.
const {
Fabric,
Pivot,
PivotItem,
TextField,
PrimaryButton,
Stack
} = window.FluentUIReact;
const Demo = () => {
return (
<Fabric>
<form>
<Pivot aria-label="Basic Pivot Example">
<PivotItem headerText="My Files">
<Stack tokens={{ childrenGap: 10 }}>
<TextField label="Name" required />
<TextField label="Email" type="email" required />
<PrimaryButton text="Submit" onClick={() => alert('Form submitted!')} />
</Stack>
</PivotItem>
<PivotItem headerText="Recent">
Pivot #2
</PivotItem>
<PivotItem headerText="Shared with me">
Pivot #3
</PivotItem>
</Pivot>
</form>
</Fabric>
);
}
ReactDOM.render(<Demo />, document.getElementById('container'));
Tired to persist the form values to manage state using React's useState hook.
本文标签: reactjsFluentUI Form Fields Resetting When Pivot ChangesStack Overflow
版权声明:本文标题:reactjs - FluentUI Form Fields Resetting When Pivot Changes - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741299371a2371003.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论