fix react warnings
This commit is contained in:
parent
53843361b6
commit
b60037b8d9
5 changed files with 73 additions and 77 deletions
10
js/app.js
10
js/app.js
|
@ -1,17 +1,15 @@
|
|||
var App = React.createClass({
|
||||
getInitialState: function() {
|
||||
// For now, routes are in format ?page or ?page=args
|
||||
var match, param, val;
|
||||
var match, param, val, viewingPage;
|
||||
[match, param, val] = window.location.search.match(/\??([^=]*)(?:=(.*))?/);
|
||||
|
||||
if (['settings', 'help', 'start', 'watch', 'report', 'files', 'claim', 'show', 'wallet', 'publish'].indexOf(param) != -1) {
|
||||
var viewingPage = param;
|
||||
} else {
|
||||
var viewingPage = 'home';
|
||||
if (param && ['settings', 'help', 'start', 'watch', 'report', 'files', 'claim', 'show', 'wallet', 'publish'].indexOf(param) != -1) {
|
||||
viewingPage = param;
|
||||
}
|
||||
|
||||
return {
|
||||
viewingPage: viewingPage,
|
||||
viewingPage: viewingPage ? viewingPage : 'home',
|
||||
pageArgs: val,
|
||||
};
|
||||
},
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
var Icon = React.createClass({
|
||||
propTypes: {
|
||||
style: React.PropTypes.object,
|
||||
fixed: React.PropTypes.boolean,
|
||||
fixed: React.PropTypes.bool,
|
||||
},
|
||||
render: function() {
|
||||
var className = 'icon ' + ('fixed' in this.props ? 'icon-fixed-width ' : '') + this.props.icon;
|
||||
|
@ -13,7 +13,7 @@ var Icon = React.createClass({
|
|||
|
||||
var TruncatedText = React.createClass({
|
||||
propTypes: {
|
||||
limit: React.PropTypes.string,
|
||||
limit: React.PropTypes.number,
|
||||
},
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
|
@ -312,7 +312,7 @@ var MenuItem = React.createClass({
|
|||
href: React.PropTypes.string,
|
||||
label: React.PropTypes.string,
|
||||
icon: React.PropTypes.string,
|
||||
onClick: React.PropTypes.function,
|
||||
onClick: React.PropTypes.func,
|
||||
},
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
|
|
|
@ -45,7 +45,7 @@ var SearchResults = React.createClass({
|
|||
var rows = [];
|
||||
this.props.results.forEach(function(result) {
|
||||
rows.push(
|
||||
<SearchResultRow name={result.name} title={result.title} imgUrl={result.thumbnail}
|
||||
<SearchResultRow key={result.name} name={result.name} title={result.title} imgUrl={result.thumbnail}
|
||||
description={result.description} cost_est={result.cost_est} />
|
||||
);
|
||||
});
|
||||
|
@ -158,7 +158,7 @@ var FeaturedContentItem = React.createClass({
|
|||
lbry.resolveName(this.props.name, (metadata) => {
|
||||
this.setState({
|
||||
metadata: metadata,
|
||||
title: metadata.title || ('lbry://' + this.props.name),
|
||||
title: metadata && metadata.title ? metadata.title : ('lbry://' + this.props.name),
|
||||
})
|
||||
});
|
||||
lbry.getCostEstimate(this.props.name, (amount) => {
|
||||
|
@ -282,7 +282,6 @@ var Discover = React.createClass({
|
|||
search: function() {
|
||||
if (this.state.query)
|
||||
{
|
||||
console.log('search');
|
||||
lbry.search(this.state.query, this.searchCallback.bind(this, this.state.query));
|
||||
}
|
||||
else
|
||||
|
@ -320,7 +319,6 @@ var Discover = React.createClass({
|
|||
},
|
||||
|
||||
render: function() {
|
||||
console.log(this.state);
|
||||
return (
|
||||
<main style={discoverMainStyle}>
|
||||
<section><input type="search" style={searchInputStyle} onChange={this.onQueryChange}
|
||||
|
|
|
@ -150,14 +150,14 @@ var MyFilesPage = React.createClass({
|
|||
if (!this.state.filesInfo.length) {
|
||||
var content = <span>You haven't downloaded anything from LBRY yet. Go <Link href="/" label="search for your first download" />!</span>;
|
||||
} else {
|
||||
var content = [];
|
||||
var content = [],
|
||||
keyIndex = 0;
|
||||
for (let fileInfo of this.state.filesInfo) {
|
||||
let {completed, written_bytes, total_bytes, lbry_uri, file_name, download_path,
|
||||
stopped, metadata} = fileInfo;
|
||||
|
||||
if (!metadata)
|
||||
{
|
||||
console.log('Empty metadata, skipping render');
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ var MyFilesPage = React.createClass({
|
|||
var ratioLoaded = written_bytes / total_bytes;
|
||||
var showWatchButton = (lbry.getMediaType(file_name) == 'video' || lbry.getMediaType(file_name) == 'audio');
|
||||
|
||||
content.push(<MyFilesRow lbryUri={lbry_uri} title={title || ('lbry://' + lbry_uri)} completed={completed} stopped={stopped}
|
||||
content.push(<MyFilesRow key={lbry_uri + (++keyIndex)} lbryUri={lbry_uri} title={title || ('lbry://' + lbry_uri)} completed={completed} stopped={stopped}
|
||||
ratioLoaded={ratioLoaded} imgUrl={thumbnail} path={download_path}
|
||||
showWatchButton={showWatchButton} pending={pending} />);
|
||||
}
|
||||
|
|
|
@ -304,8 +304,8 @@ var PublishPage = React.createClass({
|
|||
<label htmlFor="title">Title</label><FormField type="text" ref="meta_title" name="title" placeholder="My Show, Episode 1" style={publishFieldStyle} />
|
||||
<label htmlFor="author">Author</label><FormField type="text" ref="meta_author" name="author" placeholder="My Company, Inc." style={publishFieldStyle} />
|
||||
<label htmlFor="license">License info</label><FormField type="text" ref="meta_license" name="license" defaultValue="Creative Commons Attribution 3.0 United States" style={publishFieldStyle} />
|
||||
<label htmlFor="language">Language</label> <FormField type="select" ref="meta_language" name="language">
|
||||
<option value="en" selected>English</option>
|
||||
<label htmlFor="language">Language</label> <FormField type="select" defaultValue="en" ref="meta_language" name="language">
|
||||
<option value="en">English</option>
|
||||
<option value="zh">Chinese</option>
|
||||
<option value="fr">French</option>
|
||||
<option value="de">German</option>
|
||||
|
|
Loading…
Add table
Reference in a new issue