Skip to content

Commit

Permalink
feat(Logs): adds forwading ref.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Firsov committed Aug 29, 2019
1 parent c539e0b commit 36446d6
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/components/Logs/Logs.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
// @flow
import React from 'react';
import React, { forwardRef } from 'react';
import { LogsContainerTag, LogMessageTag } from './Logs.theme';

type LogsProps = {
messages: string[],
messages: React$Node[],
stretch?: Boolean,
};

const Logs = ({ messages, stretch }: LogsProps) => {
return (
<LogsContainerTag stretch={ stretch }>
const Logs = forwardRef<LogsProps, LogsContainerTag>(
({ messages = [], stretch, children, ...rest }: LogsProps, ref) => (
<LogsContainerTag stretch={ stretch } insideRef={ ref } { ...rest }>
{ React.Children.toArray(messages.map(message => (
<LogMessageTag>{ message }</LogMessageTag> // eslint-disable-line
))) }
</LogsContainerTag>
);
};
),
);

Logs.defaultProps = {
messages: [],
};
export { Logs };

export {
Logs,
};

0 comments on commit 36446d6

Please sign in to comment.