Skip to content

Commit

Permalink
Merge pull request #40 from ArondeParon/main
Browse files Browse the repository at this point in the history
Allow `null` values in trailing and leading actions
  • Loading branch information
marekrozmus authored Jun 24, 2023
2 parents 38a60e5 + 2678bdc commit 39cebe6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/LeadingActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ const LeadingActions = ({ children }) => {
}

if (Array.isArray(children)) {
return React.Children.map(children, (child, index) =>
React.cloneElement(child, {
return React.Children.map(children, (child, index) => {
if (!React.isValidElement(child)) {
return child;
}
return React.cloneElement(child, {
leading: true,
main: index === 0,
})
);
});
}

return React.cloneElement(children, {
Expand Down
9 changes: 6 additions & 3 deletions src/TrailingActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ const TrailingActions = ({ children }) => {
}

if (Array.isArray(children)) {
return React.Children.map(children, (child, index) =>
React.cloneElement(child, {
return React.Children.map(children, (child, index) => {
if (!React.isValidElement(child)) {
return child;
}
return React.cloneElement(child, {
main: index === children.length - 1,
trailing: true,
})
);
});
}

return React.cloneElement(children, {
Expand Down

0 comments on commit 39cebe6

Please sign in to comment.