Created
January 10, 2020 00:10
-
-
Save fernandocamargo/699a43f9b60cb1d0406260451e5b7f2e to your computer and use it in GitHub Desktop.
Recursive prop-types (menu-like)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { func, node, oneOf, oneOfType, shape, string } from 'prop-types'; | |
import items from './items'; | |
export const item = { | |
id: string.isRequired, | |
children: node.isRequired, | |
url: oneOfType([string, func]), | |
target: oneOf(['_blank']), | |
}; | |
export default function() { | |
return shape({ ...item, items }).apply(this, arguments); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { arrayOf } from 'prop-types'; | |
import item from './item'; | |
export default function() { | |
return arrayOf(item).apply(this, arguments); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated:
item.js
items.js