Skip to content

Commit 3b90e1c

Browse files
update: example/demo (#2585)
* update: example/demo - fix eslint config and lint issues - fix react key issue - remove children passed as props - remove unused variables and imports - "encodings_fragment" is deprecated, replaced it with "colorspace_fragment" * update: remove --fix
1 parent 88ef340 commit 3b90e1c

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

examples/demo/.eslintrc.cjs

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
/* eslint-env node */
22

33
module.exports = {
4+
root: true,
45
env: { browser: true, es2020: true },
5-
extends: [
6-
'eslint:recommended',
7-
'plugin:react/recommended',
8-
'plugin:react/jsx-runtime',
9-
'plugin:react-hooks/recommended',
10-
],
6+
extends: ['eslint:recommended', 'plugin:react/recommended', 'plugin:react/jsx-runtime', 'plugin:react-hooks/recommended'],
117
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
128
settings: { react: { version: '18.2' } },
139
plugins: ['react-refresh'],
1410
rules: {
15-
'react-refresh/only-export-components': [
16-
'warn',
17-
{ allowConstantExport: true },
18-
],
11+
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
12+
'react/prop-types': 0,
13+
'import/extensions': ['off'],
14+
'react/no-unknown-property': ['off'],
1915
},
2016
}

examples/demo/.prettierrc

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"semi": false,
3-
"trailingComma": "all",
4-
"singleQuote": true,
5-
"tabWidth": 2,
6-
"printWidth": 140,
7-
"jsxBracketSameLine": true
8-
}
2+
"semi": false,
3+
"trailingComma": "all",
4+
"singleQuote": true,
5+
"tabWidth": 2,
6+
"printWidth": 140,
7+
"jsxBracketSameLine": true
8+
}

examples/demo/src/components/CodePreview.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export default function CodePreview() {
2222
// position is set to relative so the copy button can align to bottom right
2323
<pre className={className} style={{ ...style, position: 'relative' }}>
2424
{tokens.map((line, i) => (
25-
<div {...getLineProps({ line, key: i })}>
25+
<div {...getLineProps({ line })} key={i}>
2626
{line.map((token, key) => (
27-
<span {...getTokenProps({ token, key })} />
27+
<span {...getTokenProps({ token })} key={key} />
2828
))}
2929
</div>
3030
))}

examples/demo/src/components/Details.jsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ export default function Details() {
22
return (
33
<>
44
<nav className="nav">
5-
<a href="https://docs.pmnd.rs/zustand" children="Documentation" />
6-
<a href="https://github.com/pmndrs/zustand" children="Github" />
5+
<a href="https://docs.pmnd.rs/zustand">Documentation</a>
6+
<a href="https://github.com/pmndrs/zustand">Github</a>
77
</nav>
88
<div className="bottom">
9-
<a href="https://github.com/pmndrs/zustand/tree/main/examples/demo" className="bottom-right" children="<Source />" />
10-
<a href="https://www.instagram.com/tina.henschel/" className="bottom-left" children="Illustrations @ Tina Henschel" />
9+
<a href="https://github.com/pmndrs/zustand/tree/main/examples/demo" className="bottom-right">
10+
{'<Source />'}
11+
</a>
12+
<a href="https://www.instagram.com/tina.henschel/" className="bottom-left">
13+
Illustrations @ Tina Henschel
14+
</a>
1115
</div>
1216
<span className="header-left">Zustand</span>
1317
</>

examples/demo/src/components/Fireflies.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { Vector3, CatmullRomCurve3 } from 'three'
2-
import React, { useRef, useMemo } from 'react'
2+
import { useRef, useMemo } from 'react'
33
import { extend, useFrame } from '@react-three/fiber'
44
import * as meshline from 'meshline'
55

66
extend(meshline)
77

88
const r = () => Math.max(0.2, Math.random())
99

10-
function Fatline({ curve, width, color }) {
10+
function Fatline({ curve, color }) {
1111
const material = useRef()
1212
useFrame((state, delta) => (material.current.uniforms.dashOffset.value -= delta / 100))
1313
return (
@@ -21,7 +21,7 @@ function Fatline({ curve, width, color }) {
2121
export default function Fireflies({ count, colors, radius = 10 }) {
2222
const lines = useMemo(
2323
() =>
24-
new Array(count).fill().map((_, index) => {
24+
new Array(count).fill().map(() => {
2525
const pos = new Vector3(Math.sin(0) * radius * r(), Math.cos(0) * radius * r(), 0)
2626
const points = new Array(30).fill().map((_, index) => {
2727
const angle = (index / 20) * Math.PI * 2

examples/demo/src/components/Scene.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Mesh, PlaneGeometry, Group, Vector3, MathUtils } from 'three'
2-
import React, { useRef, useState, useLayoutEffect } from 'react'
2+
import { memo, useRef, useState, useLayoutEffect } from 'react'
33
import { createRoot, events, extend, useFrame } from '@react-three/fiber'
44
import { Plane, useAspect, useTexture } from '@react-three/drei'
55
import { EffectComposer, DepthOfField, Vignette } from '@react-three/postprocessing'
@@ -106,7 +106,7 @@ function Canvas({ children }) {
106106
window.addEventListener('resize', resize)
107107
root.current.render(children)
108108
return () => window.removeEventListener('resize', resize)
109-
}, [])
109+
}, [children])
110110

111111
return <canvas ref={canvas} style={{ position: 'relative', width: '100%', height: '100%', overflow: 'hidden', display: 'block' }} />
112112
}

examples/demo/src/materials/layerMaterial.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const LayerMaterial = shaderMaterial(
2222
mat3 m = mat3(c, 0, s, 0, 1, 0, -s, 0, c);
2323
transformed = transformed * m;
2424
vNormal = vNormal * m;
25-
}
25+
}
2626
gl_Position = projectionMatrix * modelViewMatrix * vec4(transformed, 1.);
2727
}`,
2828
` uniform float time;
@@ -38,7 +38,7 @@ const LayerMaterial = shaderMaterial(
3838
if (color.a < 0.1) discard;
3939
gl_FragColor = vec4(color.rgb, .1);
4040
#include <tonemapping_fragment>
41-
#include <encodings_fragment>
41+
#include <colorspace_fragment>
4242
}`,
4343
)
4444

0 commit comments

Comments
 (0)