-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
35 lines (28 loc) · 757 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* eslint react/prop-types: 0 */
import React, { Component, createRef } from 'react'
import { createRoot } from 'react-dom/client'
import withForwardedRef from '../dist/esm'
// example component
const Comp = ({ children, className, forwardedRef }) => (
<div className={className} ref={forwardedRef}>
{children}
</div>
)
// usage of withForwardedRef
const WrappedComp = withForwardedRef(Comp)
class App extends Component {
constructor(...params) {
super(...params)
this.ref = createRef()
}
render() {
return (
<WrappedComp className="foo" ref={this.ref}>
Testing 123
</WrappedComp>
)
}
}
const container = document.querySelector('[data-app]')
const root = createRoot(container)
root.render(<App />)