Skip to content

Commit d5569da

Browse files
committed
Update README
Add hook desc
1 parent f0c7443 commit d5569da

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ import { SimpleShaderCanvas } from 'simple-shader-component/react'
2929
```
3030
***Note**: Right now only the React wrapper is included. If there's interest, or if my workflow requires it, I will add additional wrappers.*
3131

32+
### Hooks
33+
Hooks can be added to any of the class methods, to add a hook you can pass it on construction or using the exposed add hook method.
34+
35+
```tsx
36+
import { Shader, MethodName } from 'simple-shader-component' // import types from base package
37+
38+
const hook = {
39+
methodName: MethodName.RENDER,
40+
hook: (shader: Shader) => void
41+
}
42+
43+
Shader.addHook(hook) // use addHook method
44+
<SimpleShaderCanvas args={{ hooks:[hook] }} /> // or pass on init
45+
```
46+
3247
### Basic Usage
3348
'use client' directive is required to set hooks. If you're not using hooks it can be done in a server component.
3449

0 commit comments

Comments
 (0)