I have an SFC React component with Flow running like so:
// @flow
import React from 'react';
type Props = {
placeholderText?: string,
};
const defaultProps = {
placeholderText: '',
};
const Textarea = (props: Props) => (
<textarea placeholder={`${props.placeholderText}`} />
);
Textarea.defaultProps = defaultProps;
export default Textarea;
I get the following error from Flow:
Cannot coerce 'props.placeholderText' to string because undefined[1] should not be coerced (References: [1])
Can someone explain what this is about and what the fix would be?
As far as I can tell, I have explicitly told Flow that the placeholderText
IS a string, and furthermore, since it's not a required prop, I've set a default prop as an empty string, so it's never null or undefined.