File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Logs
2+ logs
3+ * .log
4+ npm-debug.log *
5+ yarn-debug.log *
6+ yarn-error.log *
7+ pnpm-debug.log *
8+ lerna-debug.log *
9+
10+ node_modules
11+ dist
12+ dist-ssr
13+ * .local
14+
15+ # Editor directories and files
16+ .vscode /*
17+ ! .vscode /extensions.json
18+ .idea
19+ .DS_Store
20+ * .suo
21+ * .ntvs *
22+ * .njsproj
23+ * .sln
24+ * .sw ?
Original file line number Diff line number Diff line change 1+ # react-use-intercom in a Vite app
2+
3+ Replace ` INTERCOM_APP_ID ` with your Intercom app id.
Original file line number Diff line number Diff line change 1+ import js from '@eslint/js'
2+ import globals from 'globals'
3+ import react from 'eslint-plugin-react'
4+ import reactHooks from 'eslint-plugin-react-hooks'
5+ import reactRefresh from 'eslint-plugin-react-refresh'
6+
7+ export default [
8+ { ignores : [ 'dist' ] } ,
9+ {
10+ files : [ '**/*.{js,jsx}' ] ,
11+ languageOptions : {
12+ ecmaVersion : 2020 ,
13+ globals : globals . browser ,
14+ parserOptions : {
15+ ecmaVersion : 'latest' ,
16+ ecmaFeatures : { jsx : true } ,
17+ sourceType : 'module' ,
18+ } ,
19+ } ,
20+ settings : { react : { version : '18.3' } } ,
21+ plugins : {
22+ react,
23+ 'react-hooks' : reactHooks ,
24+ 'react-refresh' : reactRefresh ,
25+ } ,
26+ rules : {
27+ ...js . configs . recommended . rules ,
28+ ...react . configs . recommended . rules ,
29+ ...react . configs [ 'jsx-runtime' ] . rules ,
30+ ...reactHooks . configs . recommended . rules ,
31+ 'react/jsx-no-target-blank' : 'off' ,
32+ 'react-refresh/only-export-components' : [
33+ 'warn' ,
34+ { allowConstantExport : true } ,
35+ ] ,
36+ } ,
37+ } ,
38+ ]
Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < link rel ="icon " type ="image/svg+xml " href ="/vite.svg " />
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
7+ < title > Vite + React</ title >
8+ </ head >
9+ < body >
10+ < div id ="root "> </ div >
11+ < script type ="module " src ="/src/main.jsx "> </ script >
12+ </ body >
13+ </ html >
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " vite-example" ,
3+ "private" : true ,
4+ "version" : " 0.0.0" ,
5+ "type" : " module" ,
6+ "scripts" : {
7+ "dev" : " vite" ,
8+ "build" : " vite build" ,
9+ "lint" : " eslint ." ,
10+ "preview" : " vite preview"
11+ },
12+ "dependencies" : {
13+ "react" : " ^19.0.0" ,
14+ "react-dom" : " ^19.0.0" ,
15+ "react-use-intercom" : " *"
16+ },
17+ "devDependencies" : {
18+ "@eslint/js" : " ^9.19.0" ,
19+ "@types/react" : " ^19.0.8" ,
20+ "@types/react-dom" : " ^19.0.3" ,
21+ "@vitejs/plugin-react-swc" : " ^3.5.0" ,
22+ "eslint" : " ^9.19.0" ,
23+ "eslint-plugin-react" : " ^7.37.4" ,
24+ "eslint-plugin-react-hooks" : " ^5.0.0" ,
25+ "eslint-plugin-react-refresh" : " ^0.4.18" ,
26+ "globals" : " ^15.14.0" ,
27+ "vite" : " ^6.1.0"
28+ }
29+ }
Original file line number Diff line number Diff line change 1+ import { useEffect } from 'react' ;
2+ import { IntercomProvider , useIntercom } from 'react-use-intercom' ;
3+
4+ const INTERCOM_APP_ID = 'jcabc7e3' ;
5+
6+ export function App ( ) {
7+ return (
8+ < IntercomProvider
9+ appId = { INTERCOM_APP_ID }
10+ autoBoot
11+ onShow = { ( ) => alert ( 'show' ) }
12+ >
13+ < OurApp />
14+ </ IntercomProvider >
15+ ) ;
16+ }
17+
18+ function OurApp ( ) {
19+ return (
20+ < main >
21+ < p > Our App</ p >
22+ < TrackEvent />
23+ </ main >
24+ ) ;
25+ }
26+
27+ function TrackEvent ( ) {
28+ const { trackEvent, boot, shutdown } = useIntercom ( ) ;
29+
30+ useEffect ( ( ) => {
31+ trackEvent ( 'event' ) ;
32+ } , [ trackEvent ] ) ;
33+
34+ return (
35+ < >
36+ < p > Tracing event in effect</ p >
37+ < button onClick = { ( ) => boot ( ) } > Boot</ button >
38+ < button onClick = { ( ) => shutdown ( ) } > Shutdown</ button >
39+ </ >
40+ ) ;
41+ }
42+
43+ export default App ;
Original file line number Diff line number Diff line change 1+ import { StrictMode } from 'react' ;
2+ import { createRoot } from 'react-dom/client' ;
3+
4+ import { App } from './app.jsx' ;
5+
6+ createRoot ( document . getElementById ( 'root' ) ) . render (
7+ < StrictMode >
8+ < App />
9+ </ StrictMode > ,
10+ ) ;
Original file line number Diff line number Diff line change 1+ import { defineConfig } from 'vite' ;
2+ import react from '@vitejs/plugin-react-swc' ;
3+
4+ // https://vite.dev/config/
5+ export default defineConfig ( {
6+ plugins : [ react ( ) ] ,
7+ clearScreen : false ,
8+ } ) ;
You can’t perform that action at this time.
0 commit comments