14
Belirli bir şekildeki iç içe geçmiş öğeler dizisine varsayılan sahne sağlamak için React'ta bir yol var mı? Aşağıdaki örnekte Verilen React'ta iç içe şekil için varsayılan sahne nasıl sağlanır?
, benim ilk girişim beklendiği gibi ancak bu işe yaramazsa, görülebilir. Bu örnektestatic propTypes = {
heading: PT.string,
items: PT.arrayOf(PT.shape({
href: PT.string,
label: PT.string,
})).isRequired,
};
static defaultProps = {
heading: 'this works',
items: [{
href: '/',
label: ' - this does not - ',
}],
};
, aşağıdaki beklenebilir:
// Given these props
const passedInProps = {
items: [{ href: 'foo', href: 'bar' }]
};
// Would resolve to:
const props = {
heading: 'this works',
items: [
{ href: 'foo', label: ' - this does not - ' },
{ href: 'bar', label: ' - this does not - ' },
]
};