Skip to content

Commit

Permalink
Merge pull request #266 from lucant/fix-react-default-pops
Browse files Browse the repository at this point in the history
Fixing react defaultProps
  • Loading branch information
KittyGiraudel authored Jan 20, 2025
2 parents 904fee7 + 2da3c27 commit abdaf57
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ FootnoteRef.propTypes = {
id: PropTypes.string,
}

export const Footnotes = props => {
export const Footnotes = ({
Wrapper = 'footer',
Title = props => <h2 {...props}>Footnotes</h2>,
List = 'ol',
ListItem = 'li',
BackLink = props => <a {...props}></a>,
}) => {
const { footnotes, footnotesTitleId } = React.useContext(FootnotesContext)
const { Wrapper, Title, List, ListItem, BackLink } = props

if (footnotes.size === 0) return null

Expand All @@ -75,11 +80,7 @@ export const Footnotes = props => {
<Title data-a11y-footnotes-title id={footnotesTitleId} />
<List data-a11y-footnotes-list>
{references.map(({ idNote, idRef, description }, index) => (
<ListItem
id={idNote}
key={idNote}
data-a11y-footnotes-list-item
>
<ListItem id={idNote} key={idNote} data-a11y-footnotes-list-item>
{description}&nbsp;
<BackLink
data-a11y-footnotes-back-link
Expand All @@ -94,15 +95,10 @@ export const Footnotes = props => {
)
}

Footnotes.defaultProps = {
Wrapper: 'footer',
Title: props => <h2 {...props}>Footnotes</h2>,
List: 'ol',
ListItem: 'li',
BackLink: props => <a {...props}></a>,
}

export const FootnotesProvider = ({ children, footnotesTitleId }) => {
export const FootnotesProvider = ({
children,
footnotesTitleId = 'footnotes-label',
}) => {
const [footnotes, setFootnotes] = React.useState(new Map())
const getBaseId = React.useCallback(
({ id, children }) => id || getIdFromTree(children),
Expand Down Expand Up @@ -155,10 +151,6 @@ export const FootnotesProvider = ({ children, footnotesTitleId }) => {
)
}

FootnotesProvider.defaultProps = {
footnotesTitleId: 'footnotes-label',
}

function getTextFromTree(tree) {
let text = ''

Expand Down

0 comments on commit abdaf57

Please sign in to comment.