'eslint error 'value of props' is missing in props validation using React JS on moving the props from return section to a new function
I'm getting below eslint error after moving the props to a separate function.
Here is my initial code and it is getting compiled successfully:
const MessageComponent = (props) => {
const { intl } = props;
const { formatMessage, messages } = intl;
return (
<div>
{formatMessage(messages.some_message)}
</div>
);
After getting the message from a new function:
const MessageComponent = (props) => {
const { intl } = props;
const { formatMessage, messages } = intl;
const getMessage = () => (
<div>
{formatMessage(messages.some_message)}
</div>
);
return (
getMessage()
);
then getting the error:
219:63 error 'intl.messages.some_message' is missing in props validation
react/prop-types
For both cases I haven't defined default props, so what is the difference? why is it complaining?
thanks in advance!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|