@@ -78,10 +78,27 @@ Split allows you to [implement a custom impression listener](https://help.split.
7878
7979## Usage
8080
81- Now assuming you have a split named: `feature1` you can do something like:
81+ Now assuming you have a split named `feature1` you can do something like:
8282
83- ```jsx
84- <Split name = { ' feature1' } >
83+ ### Hook
84+
85+ ```tsx
86+ const [feature1, config] = useSplit('feature1');
87+ if (feature1 === 'on') {
88+ return <Feature1 />;
89+ }
90+ ```
91+
92+ Optional [attributes](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#attribute-syntax)
93+ can also be passed in:
94+ ```tsx
95+ const [feature1, config] = useSplit('feature1', { paying_customer : true } );
96+ ```
97+
98+ ### Component
99+
100+ ```tsx
101+ <Split name = " feature1" >
85102 { (value : TreatmentWithConfig ) =>
86103 value .treatment === ' on' ? this .renderComponent () : null
87104 }
@@ -90,7 +107,7 @@ Now assuming you have a split named: `feature1` you can do something like:
90107
91108You can optionally pass a list of splits:
92109
93- ```jsx
110+ ```tsx
94111<Split name = { [' feature1' , ' feature2' ]} >
95112 { (values : TreatmentsWithConfig ) => {
96113 console .log (values );
@@ -103,6 +120,17 @@ You can optionally pass a list of splits:
103120</Split >
104121```
105122
123+ ### Tracking
124+
125+ We have a `useTrack` hook which returns the a function with the same signature as
126+ [`client.track`](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#track).
127+ ```tsx
128+ const track = useTrack();
129+ function handleClick() {
130+ const queued = track (' user' , ' click' , ' the_button' , { foo: ' bar' });
131+ }
132+ ```
133+
106134## Contributing
107135
108136### Fork and Clone the Project
0 commit comments