Skip to content

Commit

Permalink
docs: update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Apr 18, 2024
1 parent c790ca8 commit 93f9c82
Showing 1 changed file with 39 additions and 18 deletions.
57 changes: 39 additions & 18 deletions docs/examples/multiple.tsx
Expand Up @@ -12,22 +12,43 @@ function log(value) {
console.log(value);
}

export default () => (
<div>
<div style={style}>
<Slider
range
defaultValue={[0, 10, 30]}
onChange={log}
styles={{
tracks: {
background: `linear-gradient(to right, blue, red)`,
},
track: {
background: 'transparent',
},
}}
/>
let uuid = 0;

const NodeWrapper = ({ children }: { children: React.ReactElement }) => {
const [id] = React.useState(() => {
uuid += 1;
return uuid;
});

return <div>{React.cloneElement(children, {}, <div>{id}</div>)}</div>;
};

export default () => {
const [value, setValue] = React.useState([0, 10, 30]);

return (
<div>
<div style={style}>
<Slider
range
// defaultValue={[0, 10, 30]}
// onChange={log}
value={value}
onChange={(nextValue) => {
console.log('>>>', nextValue);
setValue(nextValue as any);
}}
handleRender={(node) => <NodeWrapper>{node}</NodeWrapper>}
styles={{
tracks: {
background: `linear-gradient(to right, blue, red)`,
},
track: {
background: 'transparent',
},
}}
/>
</div>
</div>
</div>
);
);
};

0 comments on commit 93f9c82

Please sign in to comment.