Skip to content

Instantly share code, notes, and snippets.

@mqklin
Created December 11, 2018 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mqklin/56343c49f883172a69cdfda6baf96237 to your computer and use it in GitHub Desktop.
Save mqklin/56343c49f883172a69cdfda6baf96237 to your computer and use it in GitHub Desktop.
0x
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