first commit
This commit is contained in:
commit
8f13dec0e4
15 files changed
+223
No files matched your search
+13
@@ -0,0 +1,13 @@
|
|||||||
|
# Local
|
||||||
|
.DS_Store
|
||||||
|
*.local
|
||||||
|
*.log*
|
||||||
|
|
||||||
|
# Dist
|
||||||
|
node_modules
|
||||||
|
dist/
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# Lock files
|
||||||
|
package-lock.json
|
||||||
|
pnpm-lock.yaml
|
||||||
|
yarn.lock
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"singleQuote": true
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Rsbuild Project
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Install the dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get Started
|
||||||
|
|
||||||
|
Start the dev server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Build the app for production:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm build
|
||||||
|
```
|
||||||
|
|
||||||
|
Preview the production build locally:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm preview
|
||||||
|
```
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
|
||||||
|
import js from '@eslint/js';
|
||||||
|
import reactHooks from 'eslint-plugin-react-hooks';
|
||||||
|
import reactJsx from 'eslint-plugin-react/configs/jsx-runtime.js';
|
||||||
|
import react from 'eslint-plugin-react/configs/recommended.js';
|
||||||
|
import globals from 'globals';
|
||||||
|
import ts from 'typescript-eslint';
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{ languageOptions: { globals: globals.browser } },
|
||||||
|
js.configs.recommended,
|
||||||
|
...ts.configs.recommended,
|
||||||
|
...fixupConfigRules([
|
||||||
|
{
|
||||||
|
...react,
|
||||||
|
settings: {
|
||||||
|
react: { version: 'detect' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
reactJsx,
|
||||||
|
]),
|
||||||
|
{
|
||||||
|
plugins: {
|
||||||
|
'react-hooks': fixupPluginRules(reactHooks),
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...reactHooks.configs.recommended.rules,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ ignores: ['dist/'] },
|
||||||
|
];
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"name": "react-renders",
|
||||||
|
"private": true,
|
||||||
|
"version": "1.0.0",
|
||||||
|
"scripts": {
|
||||||
|
"build": "rsbuild build",
|
||||||
|
"dev": "rsbuild dev --open",
|
||||||
|
"format": "prettier --write .",
|
||||||
|
"lint": "eslint .",
|
||||||
|
"preview": "rsbuild preview"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"react": "^18.3.1",
|
||||||
|
"react-dom": "^18.3.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/compat": "^1.1.1",
|
||||||
|
"@eslint/js": "^9.9.1",
|
||||||
|
"@rsbuild/core": "1.0.1-rc.0",
|
||||||
|
"@rsbuild/plugin-react": "1.0.1-rc.0",
|
||||||
|
"@types/react": "^18.3.4",
|
||||||
|
"@types/react-dom": "^18.3.0",
|
||||||
|
"eslint": "^9.9.1",
|
||||||
|
"eslint-plugin-react": "^7.35.0",
|
||||||
|
"eslint-plugin-react-hooks": "^4.6.2",
|
||||||
|
"globals": "^15.9.0",
|
||||||
|
"prettier": "^3.3.3",
|
||||||
|
"typescript": "^5.5.2",
|
||||||
|
"typescript-eslint": "^8.2.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { defineConfig } from '@rsbuild/core';
|
||||||
|
import { pluginReact } from '@rsbuild/plugin-react';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [pluginReact()],
|
||||||
|
});
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
color: #fff;
|
||||||
|
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
|
||||||
|
background-image: linear-gradient(to bottom, #020917, #101725);
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
display: flex;
|
||||||
|
min-height: 100vh;
|
||||||
|
line-height: 1.1;
|
||||||
|
text-align: center;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content h1 {
|
||||||
|
font-size: 3.6rem;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content p {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-weight: 400;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
import './App.css';
|
||||||
|
import { Parent } from './children-render/parent';
|
||||||
|
|
||||||
|
const App = () => {
|
||||||
|
return (
|
||||||
|
<div className="content">
|
||||||
|
<Parent />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default App;
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
type ChildrenProps = {
|
||||||
|
counter: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Children = (props: ChildrenProps) => {
|
||||||
|
console.log('__children render');
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h6>I'm its child</h6>
|
||||||
|
<p>My counter is {props.counter}</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import { Children } from './children';
|
||||||
|
|
||||||
|
export const Parent = () => {
|
||||||
|
console.log('__parent render');
|
||||||
|
const [counter, setCounter] = useState(0);
|
||||||
|
const [childrenCounter, setChildrenCounter] = useState(0);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h4>I'm the parent</h4>
|
||||||
|
<button onClick={() => setCounter((prev) => prev + 1)}>
|
||||||
|
Change own state! {counter}
|
||||||
|
</button>
|
||||||
|
<button onClick={() => setChildrenCounter((prev) => prev + 1)}>
|
||||||
|
Change children state!
|
||||||
|
</button>
|
||||||
|
<div>
|
||||||
|
<h5>These are my children</h5>
|
||||||
|
<Children counter={childrenCounter} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
/// <reference types="@rsbuild/core/types" />
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom/client';
|
||||||
|
import App from './App';
|
||||||
|
|
||||||
|
const rootEl = document.getElementById('root');
|
||||||
|
if (rootEl) {
|
||||||
|
const root = ReactDOM.createRoot(rootEl);
|
||||||
|
root.render(
|
||||||
|
<React.StrictMode>
|
||||||
|
<App />
|
||||||
|
</React.StrictMode>,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2020",
|
||||||
|
"lib": ["DOM", "ES2020"],
|
||||||
|
"module": "ESNext",
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"noEmit": true,
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
"allowImportingTsExtensions": true
|
||||||
|
},
|
||||||
|
"include": ["src"]
|
||||||
|
}
|
||||||
Reference in new issue
Block a user