Skip to content

Instantly share code, notes, and snippets.

@tajo
Last active April 27, 2019 18:59
Show Gist options
  • Save tajo/a84d96f248d454d1226e12bb07c81578 to your computer and use it in GitHub Desktop.
Save tajo/a84d96f248d454d1226e12bb07c81578 to your computer and use it in GitHub Desktop.
import React, {useState} from 'react';
import {List, StyledList} from 'baseui/dnd-list';
function App() {
const [items, setItems] = useState([
{ label: 'Item 1', type: 'basic'},
{ label: 'Item 2', type: 'custom'}
]);
return <List
items={this.state.items}
overrides={{
Item: {
component: ({$item}) => {
switch($item.type) {
case 'custom':
return <MyCustomItem>{$item.label}</MyCustomItem>;
default:
return <StyledItem>{$item.label}</StyledItem>;
},
},
},
}}
onChange={/* setItem(...) */}
/>
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment