自定义组件
See source code to learn the custom markdown rules.
Code
Playground
tsx
import Test from './Test'
import './App.css'
function App() {
return (
<div onClick={() => console.log('App')}>
<h1 className="app">App - {Math.random()}</h1>
<Test text="Test1" />
</div>
)
}
export default App
static
<div class="test" onclick="console.log(111)">hello</div>
meta
import { useRef, useEffect } from 'react'
import * as THREE from 'three'
import { buildCamera, buildRenderer } from './utils'
function ThreeLearnPrimitivesBox() {
const containerRef = useRef<HTMLDivElement>(null)
useEffect(() => {
const renderer = buildRenderer(containerRef)
const scene = new THREE.Scene()
const camera = buildCamera(10, 10, 10)
const box = new THREE.BoxGeometry(4, 4, 4)
const material = new THREE.MeshBasicMaterial({ color: 0x3451b2 })
const mesh = new THREE.Mesh(box, material)
// 获取 box 的边界
const edges = new THREE.EdgesGeometry(box)
const edgesMaterial = new THREE.LineBasicMaterial({
color: 0x00ffff,
})
const line = new THREE.LineSegments(edges, edgesMaterial)
mesh.add(line)
scene.add(mesh)
function render() {
renderer.render(scene, camera)
}
function animate() {
requestAnimationFrame(animate)
mesh.rotation.x += 0.01
mesh.rotation.y += 0.01
mesh.rotation.z += 0.01
render()
}
const cancelRaf = animate()
return cancelRaf
}, [])
return <div ref={containerRef} />
}
export default ThreeLearnPrimitivesBox
Runner
simple
function log(n: any) {
console.log(n)
}
log(1)
log('ch')
log({ obj: 1 })
log([1, 2, 3])
log(function t() {})
log(() => {
console.log(1)
})
log(Symbol('foo'))
log(undefined)
log(null)
log(true)
log(/foo/)
log(new Date(Date.now()))
long time
const start = Date.now()
console.log('start')
while (Date.now() - start < 3000) {}
console.log('end')
Switcher
npm install @plumbiu/react-store
Block
Diff
console.log('hewwo')
console.log('hello')
console.log('goodbye')
Notation:
console.log('hewwo')
console.log('hello')
console.log('goodbye')
Highlight
Line
console.log('hewwo')
console.log('hello')
console.log('goodbye')
Notation:
console.log('hewwo')
console.log('hello')
console.log('goodbye')
Word
console.log('hewwo')
console.log('hello')
console.log('goodbye')
Notation:
console.log('hewwo')
console.log('hello')
console.log('goodbye')
Show line
console.log('hewwo')
console.log('hello')
console.log('goodbye')
Path
Local
function Iframe(props: any) {
return <iframe {...props} />
}
export default Iframe
Remote
const s = 'Wow, this is from remote'
console.log(s)
Custom Component
Tip
Normal Tip
This is some description. This is some description.This is some description.
console.log('info')
This is Info
This is some description. This is some description. This is some description.
console.log('info')
This is Warn
This is some description. This is some description. This is some description.
console.log('warn')
This is Danger
This is some description. This is some description. This is some description.
console.log('danger')
This is some description. This is some description. This is some description.
console.log('info')
This is some description. This is some description. This is some description.
console.log('warn')
This is some description. This is some description. This is some description.
console.log('danger')
Details
Detail 测试
Hello World
console.log('details')
Image gallery
Injection and Table
Variable
Expression | Text | Code | Blod | Link |
---|---|---|---|---|
${foo} | Test | Test | Test | Test |
${bar.test.a} | Test | Test | Test | Test |
${bar['test'].a} | Test | Test | Test | Test |
Object:
Expression | Text | Code | Blod |
---|---|---|---|
${bar.test} | {"a":"Test"} | {"a":"Test"} | {"a":"Test"} |
${bar['test']} | {"a":"Test"} | {"a":"Test"} | {"a":"Test"} |
Emoji
Expression | Text | Code | Blod |
---|---|---|---|
:smile: | 😄 | 😄 | 😄 |
:hugs: | 🤗 | 🤗 | 🤗 |