Skip to content

Commit 537ccd7

Browse files
committed
Shorter example
1 parent d41afd4 commit 537ccd7

File tree

1 file changed

+2
-35
lines changed

1 file changed

+2
-35
lines changed

README.md

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,12 @@ See [lightscript.org](http://lightscript.org) for example code
66
and language reference documentation. A quick taste:
77

88
```coffee
9-
Item({ item, isActive, onClick }) =>
9+
Item({ item, isActive }) =>
1010
className = if isActive: 'active' else: 'inactive'
1111

12-
<li onClick={onClick} className={className}>
12+
<li className={className}>
1313
{item}
1414
</li>
15-
16-
class List extends React.Component:
17-
18-
activateItem(itemId): void =>
19-
if this.state.activeItem == itemId:
20-
this.setState({ activeItem: null })
21-
else:
22-
this.setState({ activeItem: itemId })
23-
24-
render() ->
25-
{ items, activeItem } = this.state
26-
27-
<div>
28-
{if activeItem:
29-
<p>You have selected: {activeItem}</p>
30-
else:
31-
<p>Click an item to select one!</p>
32-
}
33-
34-
<ul>
35-
{items.map((item, i) =>
36-
isActive = activeItem == item.id
37-
38-
if not item.hidden:
39-
<Item
40-
key={i}
41-
item={item}
42-
isActive={isActive}
43-
onClick={() => this.activateItem(item.id)}
44-
/>
45-
)}
46-
</ul>
47-
</div>
4815
```
4916

5017
Come hang out in [the gitter chatroom](https://gitter.im/lightscript/Lobby), where contributors can help you get started and answer any questions.

0 commit comments

Comments
 (0)