Skip to content

Commit ee58b97

Browse files
committed
v5.0.18
1 parent aa26cf3 commit ee58b97

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netdata/netdata-ui",
3-
"version": "5.0.17",
3+
"version": "5.0.18",
44
"description": "netdata UI kit",
55
"main": "dist/index.js",
66
"module": "dist/es6/index.js",

src/components/select/index.js

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useRef, useMemo, memo, useState, useEffect } from "react"
1+
import React, { useRef, useMemo } from "react"
22
import styled from "styled-components"
33
import ReactSelect, { components as defaultComponents } from "react-select"
44
import Creatable from "react-select/creatable"
@@ -84,7 +84,7 @@ const customComponents = {
8484
ValueContainer: withDataAttrs(defaultComponents.ValueContainer, "ValueContainer"),
8585
}
8686

87-
const VirtualItem = memo(({ virtualRow, child, measureElement }) => (
87+
const VirtualItem = ({ virtualRow, child }) => (
8888
<div
8989
key={virtualRow.key}
9090
style={{
@@ -95,27 +95,21 @@ const VirtualItem = memo(({ virtualRow, child, measureElement }) => (
9595
position: "absolute",
9696
}}
9797
data-index={virtualRow.index}
98-
ref={measureElement}
9998
>
10099
{child}
101100
</div>
102-
))
101+
)
103102

104-
const VirtualList = memo(({ optionsLength, children, parentRef, setIsMounted }) => {
103+
const VirtualList = ({ children, parentRef }) => {
105104
const virtualizer = useVirtualizer({
106-
count: optionsLength,
105+
count: children.length,
107106
getScrollElement: () => parentRef.current,
108-
estimateSize: () => 20,
107+
estimateSize: () => 35,
109108
overscan: 5,
110109
})
111110

112111
const virtualItems = virtualizer.getVirtualItems()
113112

114-
useEffect(() => {
115-
const timeoutId = setTimeout(setIsMounted(true), 0)
116-
return () => clearTimeout(timeoutId)
117-
}, [setIsMounted])
118-
119113
return (
120114
<div
121115
style={{
@@ -128,15 +122,13 @@ const VirtualList = memo(({ optionsLength, children, parentRef, setIsMounted })
128122
key={virtualRow.key}
129123
virtualRow={virtualRow}
130124
child={children[virtualRow.index]}
131-
measureElement={virtualizer.measureElement}
132125
/>
133126
))}
134127
</div>
135128
)
136-
})
129+
}
137130

138131
const VirtualizedMenuList = props => {
139-
const [isMounted, setIsMounted] = useState(false)
140132
const parentRef = useRef()
141133

142134
return (
@@ -149,14 +141,7 @@ const VirtualizedMenuList = props => {
149141
position: "relative",
150142
}}
151143
>
152-
<VirtualList
153-
parentRef={parentRef}
154-
optionsLength={props.options.length}
155-
isMounted={isMounted}
156-
setIsMounted={setIsMounted}
157-
>
158-
{props.children}
159-
</VirtualList>
144+
<VirtualList parentRef={parentRef}>{props.children}</VirtualList>
160145
</customComponents.MenuList>
161146
)
162147
}

0 commit comments

Comments
 (0)