Skip to content

fix: shoud determine whether the component is react.Fragment #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class TodoList extends React.Component {
return (
<div>
<button onClick={this.handleAdd}>Add Item</button>
<Animate transitionName="fade">
<Animate transitionName="fade" component={React.Fragment}>
{items}
</Animate>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/Animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ function getChildrenFromProps(props) {
function noop() {
}

function isReactFragment(component) {
return React.Fragment && component === React.Fragment;
}

class Animate extends React.Component {
static isAnimate = true; // eslint-disable-line

Expand Down Expand Up @@ -321,7 +325,7 @@ class Animate extends React.Component {
}
const Component = props.component;
if (Component) {
let passedProps = props;
let passedProps = isReactFragment(Component) ? {} : props;
if (typeof Component === 'string') {
passedProps = {
className: props.className,
Expand Down
2 changes: 1 addition & 1 deletion tests/multiple.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class TodoList extends React.Component {
});
return (
<div>
<Animate transitionName="example">
<Animate transitionName="example" component={React.Fragment}>
{items}
</Animate>
</div>
Expand Down