I am following a tutorial and they set a static object named defaultprops and after setting it this.props could be used in the same component, Why is this possible, I mean what's the function of the static defaultProps and is it a bulit in function in React.
class TestComponent extends Component {
static defaultprops = {
food: ["goatmeat", "yam"]
}
render() {
let categories = this.props.defaultprops.food.map(foods => {
return <option key={foods}>{foods}</option>
});
let {test} = this.props;
return (
<p>
{this.props.test}
</p>
);
};
}