Skip to content

Commit

Permalink
Merge pull request #9 from krjakbrjak/VNI-external-react
Browse files Browse the repository at this point in the history
Use external react
  • Loading branch information
krjakbrjak authored Nov 20, 2023
2 parents 04695af + 9291486 commit a2dd010
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 2 additions & 4 deletions src/VirtualTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function reducer<Type>(state: State<Type>, action: Action<Type>): State<Type> {
* @param {VirtualTable.Props} props Properties
* @component
*/
function VirtualTable<Type>({ height, renderer, fetcher }: Args<Type>) {
export default function VirtualTable<Type>({ height, renderer, fetcher }: Args<Type>): JSX.Element {
const ref = useRef(null);
const [collection, setCollection] = useState<LazyPaginatedCollection<Type>>(new LazyPaginatedCollection<Type>(1, fetcher));

Expand Down Expand Up @@ -174,7 +174,7 @@ function VirtualTable<Type>({ height, renderer, fetcher }: Args<Type>) {
});

if (state.items.length === 0) {
return null;
return <div />;
}

return (
Expand Down Expand Up @@ -221,5 +221,3 @@ VirtualTable.propTypes = {

VirtualTable.defaultProps = {
};

export default VirtualTable;
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
*/

import VirtualTable from './VirtualTable';
import { Result, Fetcher } from './helpers/types';

export {
VirtualTable,
Result,
Fetcher,
};
2 changes: 1 addition & 1 deletion testApp/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const fetchData = (index: number, count: number): Promise<Result<number>> => {

function App() {
return (
<VirtualTable
<VirtualTable<number>
renderer={(i) => <div style={{ padding: 5 }}>{i !== undefined ? i : 'unknown'}</div>}
height={400}
fetcher={fetchData}
Expand Down
16 changes: 15 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,23 @@ module.exports = (env = {}) => {
entry: './src/index.ts',
output: {
path: path.resolve('dist'),
filename: 'main.js',
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: [
Expand Down

0 comments on commit a2dd010

Please sign in to comment.