Declared props:
type IProps = {
user: ?Map<string, any> & Record<IUser>,
};
Assigning variables from props using destructuring:
const { user } = this.props;
const { name, surname } = user.toJS(); // <---- flow doesn't like this line
user
variable is typeof Map (immutable.js map). Have to use .toJS()
to change it into an object. But then the flow error/warning appears:
Flow: Call of method .toJS().
Method cannot be called on any member of intersection type intersection.
Was trying to handle it myself, failed miserably.
Any help highly appreciated!
It was fixed with:
const { name, surname } = user instanceof Map ? user.toJS() : {};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With