Skip to content

Commit

Permalink
fix: fix Transition warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
MikitaLisavets committed Dec 29, 2020
1 parent 3cd4dfc commit 3feb30d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 7 additions & 3 deletions packages/charts/src/TableChart.tsx
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useRef } from 'react';
import styled from 'styled-components';
import { Transition } from 'react-transition-group';

Expand Down Expand Up @@ -57,6 +57,7 @@ const TableChart: React.FC<Props> = ({
loaderText = 'No data',
}) => {
const isLoading = !data.length;
const rowRef = useRef(null);

return (
<Panel
Expand All @@ -82,9 +83,12 @@ const TableChart: React.FC<Props> = ({
<tbody>
{data.map((item, index) => (
// eslint-disable-next-line
<Transition key={index} in={true} appear timeout={100 * index}>
<Transition nodeRef={rowRef} key={index} in={true} appear timeout={100 * index}>
{state => (
<Row style={{ opacity: state === 'entered' ? 1 : 0 }}>
<Row
ref={rowRef}
style={{ opacity: state === 'entered' ? 1 : 0 }}
>
<Cell>
<Count>{index + 1}</Count>
</Cell>
Expand Down
7 changes: 5 additions & 2 deletions packages/charts/src/private/VerticalBar.tsx
@@ -1,5 +1,5 @@
import { rem } from '@heathmont/moon-utils';
import React from 'react';
import React, { useRef } from 'react';
import styled from 'styled-components';
import { Transition } from 'react-transition-group';

Expand Down Expand Up @@ -70,6 +70,8 @@ type Props = {
};

export const VerticalBar: React.FC<Props> = ({ data, axisPosition }) => {
const lineRef = useRef(null);

return (
<Container>
<Table isAutoSize={data.length < 5}>
Expand All @@ -90,9 +92,10 @@ export const VerticalBar: React.FC<Props> = ({ data, axisPosition }) => {
<Cell wide>
{axisPosition === 'center' && <Center />}
<Bar isNegative={isNegative} axisPosition={axisPosition}>
<Transition in appear timeout={0}>
<Transition nodeRef={lineRef} in appear timeout={0}>
{state => (
<Line
ref={lineRef}
style={{
width: `${state === 'entered' ? percent : 0}%`,
opacity,
Expand Down

0 comments on commit 3feb30d

Please sign in to comment.