tokenbridge-burner-wallet-p.../my-plugin/src/ui/MyElement.tsx

22 lines
578 B
TypeScript
Raw Normal View History

2020-03-20 12:14:46 -07:00
import React, { useEffect, useState } from 'react'
import { PluginElementContext } from '@burner-wallet/types'
import MyPlugin from '../MyPlugin'
2019-10-30 22:24:45 -07:00
2019-10-31 07:29:32 -07:00
const MyElement: React.FC<PluginElementContext> = ({ plugin }) => {
2020-03-20 12:14:46 -07:00
const [block, setBlock] = useState<string | null>(null)
const _plugin = plugin as MyPlugin
2019-10-30 22:24:45 -07:00
useEffect(() => {
2020-03-20 11:15:08 -07:00
_plugin.getBlockNum().then((num: number) => setBlock(num.toString()))
2020-03-20 12:14:46 -07:00
}, [])
2019-10-30 22:11:56 -07:00
return (
<div>
2019-10-30 22:24:45 -07:00
<div>Injected plugin element</div>
2020-03-20 12:14:46 -07:00
{block && <div>Current block number: {block}</div>}
2019-10-30 22:11:56 -07:00
</div>
2020-03-20 12:14:46 -07:00
)
}
2019-10-30 22:11:56 -07:00
2020-03-20 12:14:46 -07:00
export default MyElement