Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 124e0f4

Browse files
committed
Add connect to peer inputs
1 parent fcd1fbf commit 124e0f4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

examples/ipfm/src/Peers.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ const stopEventBubbling = (e) => {
77
}
88

99
class Peers extends Component {
10+
connect () {
11+
const addr = this.refs.addr.value
12+
this.props.onConnectTo(addr)
13+
}
14+
1015
render () {
1116
const peers = this.props.peers
1217
? this.props.peers.map((e, idx) => {
@@ -31,6 +36,21 @@ class Peers extends Component {
3136
<div className='Peers' onClick={this.props.onClick.bind(this)}>
3237
<h2>Connected Peers</h2>
3338
{peers}
39+
<br/>
40+
<br/>
41+
<h2>Connect to a Peer</h2>
42+
<div onClick={stopEventBubbling}>
43+
<input className="Peers-connect-input"
44+
type="text"
45+
ref="addr"
46+
placeholder='/ip4/127.0.0.1/tcp/9999/ws/ipfs/QmZGH8GeASSkSZoNLPEBu1MqtzLTERNUEwh9yTHLEF5kcW'
47+
/>
48+
<input className="Peers-connect-button"
49+
type="button"
50+
value="Connect"
51+
onClick={this.connect.bind(this)}
52+
/>
53+
</div>
3454
</div>
3555
)
3656
}

0 commit comments

Comments
 (0)