Skip to content

Commit

Permalink
Export props
Browse files Browse the repository at this point in the history
  • Loading branch information
holzmaster committed Dec 2, 2023
1 parent 35061eb commit ded20ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions src/TextLoop.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode } from "react";
import React, { PropsWithChildren, ReactNode } from "react";
import {
TransitionMotion,
spring,
Expand All @@ -9,8 +9,7 @@ import cxs from "cxs";
import { isEqual } from "./isEqual";
import { requestTimeout, clearRequestTimeout, RequestTimeout } from "./utils";

type Props = {
children?: (string | JSX.Element)[] | undefined;
export type TextLoopProps = PropsWithChildren & {
interval: number | number[];
delay: number;
adjustingSpeed: number;
Expand Down Expand Up @@ -38,7 +37,7 @@ type State = {
currentInterval: number;
};

class TextLoop extends React.Component<Props, State> {
export default class TextLoop extends React.Component<TextLoopProps, State> {
isUnMounting = false;

tickDelay: RequestTimeout | null = null;
Expand All @@ -47,7 +46,7 @@ class TextLoop extends React.Component<Props, State> {

wordBox: HTMLDivElement | null = null;

static defaultProps: Props = {
static defaultProps: TextLoopProps = {
interval: 3000,
delay: 0,
adjustingSpeed: 150,
Expand All @@ -57,7 +56,7 @@ class TextLoop extends React.Component<Props, State> {
noWrap: true,
};

constructor(props: Props) {
constructor(props: TextLoopProps) {
super(props);
const elements = React.Children.toArray(props.children);

Expand All @@ -84,8 +83,8 @@ class TextLoop extends React.Component<Props, State> {
}
}

componentDidUpdate(prevProps: Props, prevState: State): void {
const { interval, children, delay } = this.props as Props;
componentDidUpdate(prevProps: TextLoopProps, prevState: State): void {
const { interval, children, delay } = this.props as TextLoopProps;
const { currentWordIndex } = this.state;

const currentInterval = Array.isArray(interval)
Expand Down Expand Up @@ -286,5 +285,3 @@ class TextLoop extends React.Component<Props, State> {
);
}
}

export default TextLoop;
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as TextLoop } from "./TextLoop";
export { default as TextLoop, TextLoopProps } from "./TextLoop";

0 comments on commit ded20ef

Please sign in to comment.