Skip to content

Commit

Permalink
chores(template/react): Update to React 18 (oven-sh#627)
Browse files Browse the repository at this point in the history
* Updated react example template

* build:(landing) automated website build

* removed bun.lockb and most of changes from react example index.html

Co-authored-by: rubinj30 <rubinj30@users.noreply.github.com>
  • Loading branch information
rubinj30 and rubinj30 authored Jul 15, 2022
1 parent 9eac93d commit b901f55
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
12 changes: 5 additions & 7 deletions examples/react/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
{
"name": "@bun-examples/react",
"version": "0.0.47",
"version": "0.1.0",
"dependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2",
"web-vitals": "^1.0.1"
"react": "^18.2.0",
"react-dom": "^18.2.0",
"web-vitals": "^2.1.4"
},
"scripts": {},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
"react-app"
]
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion examples/react/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logo from "./logo.svg";
import * as React from "react";
import "./App.css";

function App() {
Expand Down
20 changes: 13 additions & 7 deletions examples/react/src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import * as React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

ReactDOM.render(
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById("root")
</React.StrictMode>
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
13 changes: 13 additions & 0 deletions examples/react/src/reportWebVitals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const reportWebVitals = onPerfEntry => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};

export default reportWebVitals;

0 comments on commit b901f55

Please sign in to comment.