Skip to content

Commit

Permalink
fix: add nodeRef
Browse files Browse the repository at this point in the history
BREAKING CHANGE: version incompatible

ref #8
  • Loading branch information
zhyd1997 committed Jun 18, 2020
1 parent ead823f commit c407825
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/components/DishDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ const DishDetail = (props) => {
</div>
</div>
);
} else {
return (
<div></div>
);
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/components/Home.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, {useRef} from "react";
import {
Card,
CardImg,
Expand All @@ -12,6 +12,7 @@ import { baseUrl } from "../shared/baseUrl";
import { FadeTransform } from 'react-animation-components';

function RenderCard({item, isLoading, errMess}) {
const nodeRef = useRef(null);
if (isLoading) {
return (
<Loading />
Expand All @@ -22,7 +23,7 @@ function RenderCard({item, isLoading, errMess}) {
);
} else {
return (
<FadeTransform in transformProps={{ exitTransform: 'scale(0.5) translateY(-50%)' }}>
<FadeTransform nodeRef={nodeRef} in transformProps={{ exitTransform: 'scale(0.5) translateY(-50%)' }}>
<Card>
<CardImg src={baseUrl + item.image} alt={item.name}/>
<CardBody>
Expand Down
16 changes: 12 additions & 4 deletions src/components/Main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from "react";
import React, {Component, useRef} from "react";
import Menu from "./Menu";
import DishDetail from "./DishDetail";
import Header from "./Header";
Expand Down Expand Up @@ -74,11 +74,12 @@ class Main extends Component {
);
};

return (
<div>
<Header />
const MainRoutes = () => {
const nodeRef = useRef(null);
return (
<TransitionGroup>
<CSSTransition
nodeRef={nodeRef}
key={this.props.location.key}
classNames="page"
timeout={300}
Expand All @@ -100,6 +101,13 @@ class Main extends Component {
</Switch>
</CSSTransition>
</TransitionGroup>
);
}

return (
<div>
<Header />
<MainRoutes />
<Footer />
</div>
);
Expand Down

0 comments on commit c407825

Please sign in to comment.