Skip to content

Instantly share code, notes, and snippets.

@otherjohn
Created July 16, 2016 16:16
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 otherjohn/1964a70d15b6234556f48179ac1604c9 to your computer and use it in GitHub Desktop.
Save otherjohn/1964a70d15b6234556f48179ac1604c9 to your computer and use it in GitHub Desktop.
Cant find the cause of "type.toUpperCase is not a function"
import alt from '../alt';
import request from 'superagent';
import config from '../config';
var NProgress = require('NProgress');
class AuthorActions {
loadSingleAuthor(id, cb){
var self = this;
NProgress.start();
request.get(config.baseUrl+'/users/'+ id, function(err, response){
self.actions.updateCurrentAuthor(response.body);
setTimeout(function(){
NProgress.done();
},500);
if(cb){
cb();
}
} )
}
updateCurrentAuthor(author){
this.dispatch(author);
}
}
module.exports = alt.createActions(AuthorActions);
var Alt = require('alt');
var alt = new Alt();
module.exports = alt;
var React = require('react');
import WtmAuthor from './components/WtmAuthor.jsx';
React.render(
<WtmAuthor />,
document.getElementById('wtm-author')
);
var React = require('react');
import AuthorStore from '../stores/AuthorStore';
let WtmAuthor = React.createClass({
contextTypes: {
router: React.PropTypes.func
},
getInitialState: function() {
return AuthorStore.getState();
},
componentDidMount: function(){
AuthorStore.listen(this.onChange);
},
componentWillUnmount: function() {
AuthorStore.unlisten(this.onChange);
},
onChange: function(state) {
this.setState(state);
},
render: function() {
return (
<div className="author_bio_section">
<h4>ABOUT THE AUTHOR</h4>
<div className="wtm__avitar">
[image]
</div>
<div className="author_details">
<p className="author_name">{this.state.currentAuthor.name}</p>
<p className="author_bio"> [bio]</p>
<p className="author_links"><a href="[author_page]">View all posts by [author]</a></p>
</div>
</div>
);
}
});
module.export = WtmAuthor;
var config = { baseUrl: "http://design.wtm.dev/wp-json/v2" };
module.exports = config;
import alt from '../alt';
import AuthorActions from '../actions/AuthorActions';
class AuthorStore {
constructor() {
var self = this;
this.bindListeners({
updateCurrentAuthor: AuthorActions.UPDATE_CURRENT_AUTHOR
});
this.on('init', function(){
self.currentAuthor = null;
})
}
updateCurrentAuthor(author){
this.currentAuthor = author;
}
}
module.exports = alt.createStore( AuthorStore, 'AuthorStore');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment