start to rewrite draft using preact

This commit is contained in:
igoradamenko
2018-01-23 20:15:35 +02:00
parent 446b80b5c9
commit fa821cb5e1
5 changed files with 28 additions and 7 deletions
+3 -7
View File
@@ -1,15 +1,11 @@
import { h, render } from 'preact';
import 'babel-polyfill'; // TODO: remove it
import 'mimic'; // TODO: it's for dev only
import './polyfills'; // TODO: check it
import fetcher from './fetcher';
import render from './render';
import Root from './components/root';
require('./main.scss');
// TODO: add preloader
// TODO: all of these settings must be optional params
fetcher
.get('/find?url=https://radio-t.com/p/2017/12/16/podcast-576/&sort=time&format=tree')
.then(render);
render(<Root />, document.getElementById('remark42'));
+1
View File
@@ -0,0 +1 @@
export { default } from './root';
+22
View File
@@ -0,0 +1,22 @@
import { Component } from 'preact';
import fetcher from 'fetcher';
export default class Root extends Component {
componentDidMount() {
// TODO: add preloader
// TODO: all of these settings must be optional params
fetcher
.get('/find?url=https://radio-t.com/p/2017/12/16/podcast-576/&sort=time&format=tree')
.then(this.loadData.bind(this));
}
loadData(data) {
this.setState({ data: JSON.stringify(data) })
}
render() {
const { data } = this.state;
return data;
}
}
+1
View File
@@ -1,5 +1,6 @@
import './promises';
// TODO: i think we need to use unfetch here instead of heavy axios
import axios from 'axios';
import { baseUrl, apiBase, siteId } from './settings';
+1
View File
@@ -4,6 +4,7 @@ import Promise from 'promise-polyfill';
Promise._unhandledRejectionFn = () => {};
/* eslint-enable no-underscore-dangle */
// TODO: need to figure out, do we really need finally?
/* eslint-disable no-extend-native */
Promise.prototype.finally = function finallyFn(callback) {
const constructor = this.constructor;