Created
December 11, 2018 04:03
-
-
Save mqklin/56343c49f883172a69cdfda6baf96237 to your computer and use it in GitHub Desktop.
0x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component} from 'react'; | |
import styled from 'styled-components'; | |
import {forbidExtraProps} from 'airbnb-prop-types'; | |
const Wr = styled.div` | |
`; | |
const Container = styled.div` | |
max-width: 1200px; | |
padding: 0 15px; | |
margin: auto; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
padding-top: 40px; | |
`; | |
const Iframe = styled.iframe` | |
border: 0; | |
width: 500px; | |
height: 600px; | |
`; | |
export default class Trade extends Component { | |
static propTypes = forbidExtraProps({ | |
}); | |
componentDidMount() { | |
this.iframe.contentDocument.open(); | |
this.iframe.contentDocument.write(` | |
\<script src="https://instant.0xproject.com/instant.js">\<\/script> | |
\<script> | |
const intervalId = setInterval( | |
() => { | |
if (window.zeroExInstant) { | |
clearInterval(intervalId); | |
window.zeroExInstant.render({ | |
orderSource: 'https://api.radarrelay.com/0x/v2/', | |
provider: parent.ethereum, | |
}, 'body'); | |
} | |
}, | |
300, | |
); | |
\<\/script> | |
`); | |
this.iframe.contentDocument.close(); | |
} | |
render() { | |
return ( | |
<Wr> | |
<Container> | |
<Iframe innerRef={r => this.iframe = r}/> | |
</Container> | |
</Wr> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment