Skip to content

Commit 167c27a

Browse files
committed
use component tags in shared examples
1 parent 8ba3eff commit 167c27a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

examples/viewer.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ import * as northwind from './northwind.js';
77

88

99
let el = document.querySelector('#app'),
10+
tags = {},
1011
templates = {},
1112
data = {northwind},
1213
lookup = {},
1314
links = [],
1415
key = 1;
1516

1617

18+
Object.keys(components).forEach(name => {
19+
tags['ax-' + name.toLowerCase()] = components[name];
20+
});
21+
22+
1723
function path(s){
1824
return '/' + s.replace(/^\W+|\W+$/g, '').replace(/\W+/g, '-').toLowerCase();
1925
}
@@ -35,9 +41,9 @@ function index(name){
3541
}
3642

3743

38-
function render(Component, props){
44+
function render(component, props){
3945
props.key = ++key;
40-
ReactDOM.render(React.createElement(Component, props), el);
46+
ReactDOM.render(React.createElement(tags[component], props), el);
4147
}
4248

4349

@@ -47,7 +53,7 @@ function refresh(){
4753
mode = RegExp.$1;
4854

4955
if (name && typeof lookup[name] == 'function') {
50-
lookup[name]({render}, components, templates, data);
56+
lookup[name]({render}, templates, data);
5157
}
5258
else {
5359
index(name);

0 commit comments

Comments
 (0)