Skip to content

Commit 6f35b2b

Browse files
committed
chore: export types
1 parent 2f0dda4 commit 6f35b2b

File tree

5 files changed

+29
-43
lines changed

5 files changed

+29
-43
lines changed

src/nested-list-view/nested-list-view.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ export interface IProps {
3333
keepOpenedState?: boolean;
3434
}
3535

36-
export interface IState {
37-
root: INode;
38-
}
39-
4036
const defaultRootNode = {
4137
_internalId: 'root',
4238
items: [],
@@ -45,7 +41,7 @@ const defaultRootNode = {
4541
hidden: true,
4642
} as INode;
4743

48-
const NestedListView = React.memo(
44+
const NestedListView: React.FC<IProps> = React.memo(
4945
({
5046
getChildrenName,
5147
renderNode,

src/nested-row/nested-row.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useMemo } from 'react';
2-
import { StyleSheet, View } from 'react-native';
2+
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
33

44
const styles = StyleSheet.create({
55
nestedRow: {
@@ -10,25 +10,18 @@ const styles = StyleSheet.create({
1010

1111
export interface IProps {
1212
height?: number;
13-
children: any;
1413
level?: number;
1514
paddingLeftIncrement?: number;
16-
style?: any;
15+
style?: StyleProp<ViewStyle>;
1716
}
1817

19-
const NestedRow = React.memo(
20-
({
21-
height,
22-
children,
23-
level = 0,
24-
paddingLeftIncrement = 10,
25-
style,
26-
}: IProps) => {
18+
const NestedRow: React.FC<IProps> = React.memo(
19+
({ height, children, level = 0, paddingLeftIncrement = 10, style }) => {
2720
const composedStyles = useMemo(
2821
() => [
2922
styles.nestedRow,
23+
style,
3024
{
31-
...style,
3225
paddingLeft: level * paddingLeftIncrement,
3326
},
3427
height ? { height } : {},

src/node-view/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './node-view';
2+
export * from './types';

src/node-view/node-view.tsx

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import React, { ReactElement, useCallback, useEffect, useState } from 'react';
22
import { FlatList, Pressable } from 'react-native';
33
import globalHook, { Store } from 'use-global-hook';
4-
5-
export interface INode {
6-
_internalId: string;
7-
hidden: boolean;
8-
opened: boolean;
9-
[key: string]: any;
10-
}
4+
import { GlobalState, INode, NodeActions } from './types';
115

126
export interface IProps {
137
getChildrenName: (item: INode) => string;
@@ -24,23 +18,6 @@ export interface IProps {
2418
keepOpenedState?: boolean;
2519
}
2620

27-
export interface IState {
28-
node: INode;
29-
extraData?: any;
30-
opened: boolean;
31-
}
32-
33-
interface GlobalState {
34-
nodesState: { root: boolean };
35-
}
36-
37-
interface NodeActions {
38-
setOpenedNode: (
39-
store: Store<GlobalState, NodeActions>,
40-
{ internalId, opened }: any,
41-
) => void;
42-
}
43-
4421
const actions = {
4522
setOpenedNode: (
4623
store: Store<GlobalState, NodeActions>,
@@ -59,7 +36,7 @@ const initialState: GlobalState = {
5936
// @ts-ignore
6037
const useGlobal = globalHook<GlobalState, NodeActions>(initialState, actions);
6138

62-
const NodeView = React.memo(
39+
const NodeView: React.FC<IProps> = React.memo(
6340
({
6441
renderNode,
6542
extraData,
@@ -68,7 +45,7 @@ const NodeView = React.memo(
6845
node,
6946
onNodePressed,
7047
keepOpenedState,
71-
}: IProps) => {
48+
}) => {
7249
const [globalState, globalActions]: [any, any] = useGlobal();
7350

7451
const [_node, setNode]: [INode, any] = useState({

src/node-view/types.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Store } from 'use-global-hook';
2+
3+
export interface INode {
4+
_internalId: string;
5+
hidden: boolean;
6+
opened: boolean;
7+
[key: string]: any;
8+
}
9+
10+
export interface GlobalState {
11+
nodesState: { root: boolean };
12+
}
13+
14+
export interface NodeActions {
15+
setOpenedNode: (
16+
store: Store<GlobalState, NodeActions>,
17+
{ internalId, opened }: any,
18+
) => void;
19+
}

0 commit comments

Comments
 (0)