React$ElementConfig converts props to read-only
Closed this issue · 0 comments
hrasoa commented
LazyPicure.js
type Styles: {
root: string,
};
type Props = {
alt: string,
image: { src: string, preSrc: string },
styles: ?Styles,
};
const LazyPicture = (props: Props) => { ... }
LazyPicture.defaultProps = {
styles: null,
};
index.js
import Loadable from 'react-loadable';
import typeof LazyPicture from './LazyPicture';
type Props = React$ElementConfig<LazyPicture>;
const LoadableLazyPicture: React$ComponentType<Props> = Loadable({
loader: () => import(/* webpackChunkName: "lazy-picture" */ './LazyPicture'),
loading: () => null,
});
export default LoadableLazyPicture;
Now when I run flow:
In fact in index.js, type Props
from React$ElementConfig
became read only:
type Props = {
+alt: string,
+image: {
preSrc: string,
src: string
},
+styles ? : ? Styles
}
I expected to have the same type from React$ElementConfig
I cannot use React$ElementProps
because I need to preserve the defaultProps
flow-bin@0.87.0
https://flow.org/en/docs/react/types/#toc-react-elementprops
https://flow.org/en/docs/react/types/#toc-react-elementconfig