Skip to content

Commit

Permalink
fix for React 18 strict mode (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristian Puccio authored May 9, 2023
1 parent ded5008 commit ad08e40
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
8 changes: 6 additions & 2 deletions examples/js/03-react.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import * as ReactDOM from 'react-dom/client';
import Elevio from '../../src/react';

type State = {
Expand Down Expand Up @@ -80,7 +80,11 @@ class App extends React.Component<{}, State> {
function render() {
const target = document.getElementById('root');
if (!target) throw new Error('Cant find target div');
ReactDOM.render(<App />, target);
ReactDOM.createRoot(target).render(
<React.StrictMode>
<App />
</React.StrictMode>
);
}

render();
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@
"@skypack/package-check": "^0.2.2",
"@types/ejs": "^3.0.6",
"@types/express": "^4.17.12",
"@types/prop-types": "^15.7.3",
"@types/react": "^17.0.37",
"@types/react-dom": "^17.0.11",
"@types/webpack": "^5.28.0",
"@types/webpack-dev-middleware": "^5.0.0",
"@types/prop-types": "^15.7.5",
"@types/react": "^18.2.6",
"@types/react-dom": "^18.2.4",
"@types/webpack": "^5.28.1",
"@types/webpack-dev-middleware": "^5.0.2",
"cypress": "^3.8.3",
"ejs": "^3.1.6",
"express": "^4.17.2",
"html-webpack-plugin": "^5.5.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"start-server-and-test": "^1.12.5",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
"typescript": "^4.3.5",
"webpack": "^5.41.1",
"webpack-cli": "^4.7.2",
"webpack-dev-middleware": "^5.0.0",
"webpack-dev-server": "^4.7.1"
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"typescript": "^5.0.4",
"webpack": "^5.82.0",
"webpack-cli": "^5.1.0",
"webpack-dev-middleware": "^6.1.0",
"webpack-dev-server": "^4.15.0"
},
"scripts": {
"clean": "rm -f ./lib/*; rm -f ./esm/*",
Expand All @@ -45,7 +45,7 @@
},
"dependencies": {
"fast-deep-equal": "^3.1.3",
"prop-types": "^15.8.0"
"prop-types": "^15.8.1"
},
"files": [
"lib/*",
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const ElevioExports = {
/**
* Disabled Elevio completely, if it was enabled.
*/
disable: noop as typeof disable,
disable: () => {},

/**
* Enable Elevio if it was disabled.
Expand Down
6 changes: 2 additions & 4 deletions src/elevio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export type OnEventTypes = {
'search:query': (results: {
query: string;
results: Array<{
// TODO: should be included
// category_id: string;
category_id: string;
id: string;
title: string;
}>;
Expand All @@ -52,8 +51,7 @@ export type OnEventTypes = {
*/
'search:article:clicked': (result: {
articleId: number;
// TODO: should be included
// categoryId: string;
categoryId: string;
source: string;
}) => void;

Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"declaration": true,
"esModuleInterop": true,
"removeComments": false,
"jsx": "react"
"jsx": "react",
"skipLibCheck": true
},
"exclude": ["node_modules", "lib"],
"files": ["src/index.ts"]
Expand Down

0 comments on commit ad08e40

Please sign in to comment.