Skip to content

Commit aab1de0

Browse files
committed
Convert to function component, fix demo
1 parent 175d00a commit aab1de0

File tree

10 files changed

+790
-154
lines changed

10 files changed

+790
-154
lines changed

.eslintrc.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
}
1414
},
1515
"extends": [
16-
"plugin:react/recommended",
1716
// Uses the recommended rules from @eslint-plugin-react
17+
"plugin:react/recommended",
18+
// No react-import
19+
"plugin:react/jsx-runtime",
1820
"plugin:react-hooks/recommended",
19-
"plugin:@typescript-eslint/recommended",
2021
// Uses the recommended rules from the @typescript-eslint/eslint-plugin
21-
"plugin:prettier/recommended"
22+
"plugin:@typescript-eslint/recommended",
2223
// Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array
24+
"plugin:prettier/recommended"
2325
],
2426
"rules": {
2527
}

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ A responsive container for displaying tables traditionally on wide screens and w
1010

1111
`npm install react-hyper-responsive-table`
1212

13+
This module uses `useSyncExternalStore`, which was introduced in React 18. If you are still using React 17 or older, also install
14+
[use-sync-external-store](https://www.npmjs.com/package/use-sync-external-store):
15+
16+
`npm install use-sync-external-store`
17+
1318
## Example
1419

1520
```jsx

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
],
1313

1414
['@babel/preset-env', { targets: { node: 'current' } }],
15-
'@babel/preset-react',
15+
['@babel/preset-react', { runtime: 'automatic' }],
1616
],
1717
plugins: ['@babel/plugin-transform-runtime'],
1818
};

demo/src/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { render } from 'react-dom';
32

43
import './demo.css';
@@ -59,4 +58,4 @@ const Demo = () => (
5958
</div>
6059
);
6160

62-
render(<Demo />, document.querySelector('#demo'));
61+
render(<Demo />, document.querySelector('body'));

demo/src/rollup.config.mjs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { join, dirname } from 'path';
2+
import { fileURLToPath } from 'url';
3+
import nodeResolve from '@rollup/plugin-node-resolve';
4+
import typescript from 'rollup-plugin-typescript2';
5+
import css from 'rollup-plugin-import-css';
6+
import commonjs from '@rollup/plugin-commonjs';
7+
import html from '@rollup/plugin-html';
8+
import terser from '@rollup/plugin-terser';
9+
10+
const inputDir = dirname(fileURLToPath(import.meta.url));
11+
const outputDir = join(inputDir, '..', 'dist');
12+
13+
export default {
14+
input: join(inputDir, 'index.tsx'),
15+
external: [''],
16+
output: [
17+
{
18+
dir: outputDir,
19+
format: 'es',
20+
sourcemap: false,
21+
},
22+
],
23+
plugins: [
24+
nodeResolve({ browser: true }),
25+
commonjs({}),
26+
typescript({
27+
tsconfigOverride: {
28+
compilerOptions: {
29+
declaration: false,
30+
},
31+
},
32+
}),
33+
terser({
34+
compress: { global_defs: { 'process.env.NODE_ENV': 'production' } },
35+
}),
36+
css({}),
37+
html({
38+
meta: [
39+
{ charset: 'utf-8' },
40+
{ name: 'viewport', content: 'width=device-width,initial-scale=1,shrink-to-fit=no' },
41+
],
42+
title: 'react-hyper-responsive-table demo',
43+
}),
44+
],
45+
};

0 commit comments

Comments
 (0)