Skip to content

Commit 09f9dd0

Browse files
committed
expose and use custom h function
1 parent 4e1955c commit 09f9dd0

File tree

3 files changed

+6
-25
lines changed

3 files changed

+6
-25
lines changed

examples/viewer/viewer.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11

22
import {Viewer} from '@activewidgets/examples';
3-
import React from 'react';
43
import ReactDOM from 'react-dom';
54
import * as pages from '../index.js';
6-
import * as components from '../../';
7-
8-
9-
let tags = {};
10-
11-
Object.keys(components).forEach(name => {
12-
tags['ax-' + name.toLowerCase()] = components[name];
13-
});
5+
import {h} from '../../';
146

157

168
function mount(component, props){
179
let container = document.getElementById('app');
1810
container.innerHTML = '';
19-
ReactDOM.render(React.createElement(tags[component], props), container);
11+
ReactDOM.render(h(component, props), container);
2012
}
2113

2214

js/framework.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
import adapter from '@activewidgets/frameworks/react';
33
import React from 'react';
44

5-
export const {build} = adapter(React);
5+
export const {h, build} = adapter(React);

test/adapter/react.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11

2-
import React from 'react';
3-
import {render as originalRender, fireEvent, wait, waitForElement} from '@testing-library/react';
4-
import * as components from '@activewidgets/components';
2+
import {render as _render, fireEvent, wait, waitForElement} from '@testing-library/react';
3+
import {h} from '@activewidgets/components';
54

6-
let tags = {};
7-
8-
Object.keys(components).forEach(name => {
9-
tags['ax-' + name.toLowerCase()] = components[name];
10-
});
115

126
export function render(component, props){
13-
14-
if (!tags[component]){
15-
throw new Error('component not found - ' + component);
16-
}
17-
18-
return originalRender(React.createElement(tags[component], props));
7+
return _render(h(component, props));
198
}
209

2110
export {fireEvent, wait, waitForElement};

0 commit comments

Comments
 (0)