import * as React from 'react'; import { DefaultButton, FocusZone, IStackTokens, Stack } from 'office-ui-fabric-react'; import { CollapsibleSection } from '@uifabric/experiments/lib/CollapsibleSection'; export interface ICollapsibleSectionControlledExampleState { collapsed: boolean; clicks: number; } const stackTokens: IStackTokens = { childrenGap: 20 }; /* eslint-disable react/jsx-no-bind */ export class CollapsibleSectionControlledExample extends React.Component< {}, ICollapsibleSectionControlledExampleState > { constructor(props: {}) { super(props); this.state = { collapsed: true, clicks: 0, }; } public render(): JSX.Element { return (
Even though we are using the same CollapsibleSection with the same state component, createComponent overrides the state component's output when the controlled prop has a value passed in automatically. As a result, clicking on the titles in this example does not affect collapsed state, only clicking on the Toggle button does.
Number of title clicks: {this.state.clicks}