From 735bf1967b8173414f211fa031899398bf41027e Mon Sep 17 00:00:00 2001 From: Nikita Vakula Date: Mon, 20 Nov 2023 11:06:10 +0100 Subject: [PATCH 1/3] Renamed entrypoint to index.js Signed-off-by: Nikita Vakula --- package.json | 2 +- webpack.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 19b949b..5c460e7 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/krjakbrjak/virtualtable/issues" }, "homepage": "https://github.com/krjakbrjak/virtualtable#readme", - "main": "dist/main.js", + "main": "dist/index.js", "dependencies": { "normalize.css": "^8.0.1", "prop-types": "^15.8.1", diff --git a/webpack.config.js b/webpack.config.js index c8f4b8d..cfd3975 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -8,7 +8,7 @@ module.exports = (env = {}) => { entry: './src/index.ts', output: { path: path.resolve('dist'), - filename: 'main.js', + filename: 'index.js', libraryTarget: 'commonjs2', }, plugins: [new ESLintPlugin()], From 7c5c7b0e7aaf92f0a60fcecb69b78627e9a60195 Mon Sep 17 00:00:00 2001 From: Nikita Vakula Date: Mon, 20 Nov 2023 11:06:29 +0100 Subject: [PATCH 2/3] Updated imports/exports Signed-off-by: Nikita Vakula --- src/VirtualTable.tsx | 6 ++---- src/index.ts | 3 +++ testApp/src/index.tsx | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/VirtualTable.tsx b/src/VirtualTable.tsx index 480b385..5eee1c5 100644 --- a/src/VirtualTable.tsx +++ b/src/VirtualTable.tsx @@ -81,7 +81,7 @@ function reducer(state: State, action: Action): State { * @param {VirtualTable.Props} props Properties * @component */ -function VirtualTable({ height, renderer, fetcher }: Args) { +export default function VirtualTable({ height, renderer, fetcher }: Args): JSX.Element { const ref = useRef(null); const [collection, setCollection] = useState>(new LazyPaginatedCollection(1, fetcher)); @@ -174,7 +174,7 @@ function VirtualTable({ height, renderer, fetcher }: Args) { }); if (state.items.length === 0) { - return null; + return
; } return ( @@ -221,5 +221,3 @@ VirtualTable.propTypes = { VirtualTable.defaultProps = { }; - -export default VirtualTable; diff --git a/src/index.ts b/src/index.ts index ba2eb91..0b818c8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,10 @@ */ import VirtualTable from './VirtualTable'; +import { Result, Fetcher } from './helpers/types'; export { VirtualTable, + Result, + Fetcher, }; diff --git a/testApp/src/index.tsx b/testApp/src/index.tsx index a6a1059..1e34068 100644 --- a/testApp/src/index.tsx +++ b/testApp/src/index.tsx @@ -25,7 +25,7 @@ const fetchData = (index: number, count: number): Promise> => { function App() { return ( - renderer={(i) =>
{i !== undefined ? i : 'unknown'}
} height={400} fetcher={fetchData} From 929148633762fcda15f422707c6c186824e3c90d Mon Sep 17 00:00:00 2001 From: Nikita Vakula Date: Mon, 20 Nov 2023 11:07:27 +0100 Subject: [PATCH 3/3] Depend on external React This will avoid errors when consuming projects import React as well. Signed-off-by: Nikita Vakula --- webpack.config.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/webpack.config.js b/webpack.config.js index cfd3975..ea0d8c6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -11,6 +11,20 @@ module.exports = (env = {}) => { filename: 'index.js', libraryTarget: 'commonjs2', }, + externals: { + "react": { + "commonjs": "react", + "commonjs2": "react", + "amd": "react", + "root": "React" + }, + "react-dom": { + "commonjs": "react-dom", + "commonjs2": "react-dom", + "amd": "react-dom", + "root": "ReactDOM" + } + }, plugins: [new ESLintPlugin()], module: { rules: [