@@ -14,8 +14,6 @@ Open in [CodeSandbox](https://codesandbox.io/p/sandbox/github/gridstack/gridstac
1414- [x] Custom handle
1515- [x] Drag between two grid stacks
1616
17- Welcome to give any suggestions and ideas, you can submit an issue or contact me by email. :)
18-
1917## Usage
2018
2119This is not an npm package, it's just a demo project. Please copy the ` src/lib ` code to your project to use it.
@@ -24,6 +22,37 @@ This is not an npm package, it's just a demo project. Please copy the `src/lib`
2422
2523Render item with widget id selector.
2624
25+ Code here: [ src/examples/000-simple/index.tsx] ( src/examples/000-simple/index.tsx )
26+
27+ ``` tsx
28+ function Simple() {
29+ const [uncontrolledInitialOptions] = useState <GridStackOptions >(() => ({
30+ ... defaultGridOptions ,
31+ children: [
32+ { id: " item1" , h: 2 , w: 2 , x: 0 , y: 0 },
33+ { id: " item2" , h: 2 , w: 2 , x: 2 , y: 0 },
34+ ],
35+ }));
36+
37+ return (
38+ <GridStackContainer
39+ initialOptions = { uncontrolledInitialOptions }
40+ renderRawContent
41+ >
42+ <GridStackItem id = " item1" >
43+ <div style = { { color: " yellow" }} >hello</div >
44+ </GridStackItem >
45+
46+ <GridStackItem id = " item2" >
47+ <div style = { { color: " blue" }} >grid</div >
48+ </GridStackItem >
49+ </GridStackContainer >
50+ );
51+ }
52+ ```
53+
54+ Or split the grid stack container to provide grid stack context and render component for access to grid stack context.
55+
2756Code here: [ src/examples/001-simple/index.tsx] ( src/examples/001-simple/index.tsx )
2857
2958``` tsx
@@ -38,6 +67,7 @@ function Simple() {
3867
3968 return (
4069 <GridStackProvider initialOptions = { uncontrolledInitialOptions } >
70+ { /* Custom toolbar component. Access to grid stack context by useGridStackContext hook. */ }
4171 <Toolbar />
4272
4373 <GridStackRender renderRawContent >
@@ -210,6 +240,17 @@ function CustomHandle() {
210240
211241### Components
212242
243+ #### GridStackContainer
244+
245+ Top-level component that provides GridStack context and GridStack root container. Equivalent to ` GridStackProvider ` and ` GridStackRender ` combined.
246+
247+ ``` typescript
248+ type GridStackContainerProps = {
249+ initialOptions: GridStackOptions ; // GridStack initialization options
250+ children: React .ReactNode ;
251+ };
252+ ```
253+
213254#### GridStackProvider
214255
215256Top-level component that provides GridStack context.
0 commit comments