I'm currently trying to implement a simple webapp with react and fluent ui. Right now I'm working on a toolbar with a Coachmark. But all that is not important. My function component make use of React.useState and initializes it from a property of type boolean. Directly after this the state is false, no matter what the value of that property is. Here is the relevant code snippet:
type HeadDataCommandBarProps = {
onSave: any,
onComment: any,
showCoachmark: boolean
};
const InvoiceHeadDataCommandBar: React.FunctionComponent<InvoiceHeadDataCommandBarProps> = ({ onSave, onComment, showCoachmark }) => {
console.log('showCoachmark', showCoachmark);
const [isCoachmarkVisible, setIsCoachmarkVisible] = React.useState(showCoachmark);
console.log('isCoachmarkVisible', isCoachmarkVisible);
const onDismissCoachmark = () => setIsCoachmarkVisible(false);
return (
<IndividualCommandBarButtonAsExample
onDismissCoachmark={onDismissCoachmark}
isCoachmarkVisible={isCoachmarkVisible}
onSave={onSave}
onComment={onComment}
/>
);
}
export default InvoiceHeadDataCommandBar;
This is the log output:
showCoachmark true InvoiceHeadDataCommandBar.tsx:94:12
isCoachmarkVisible false InvoiceHeadDataCommandBar.tsx:96:10
Could anybody point me in the right direction?