diff --git a/website/core/AlgoliaDocSearch.js b/website/core/AlgoliaDocSearch.js index 49cf90025..1a0e544d0 100644 --- a/website/core/AlgoliaDocSearch.js +++ b/website/core/AlgoliaDocSearch.js @@ -12,14 +12,14 @@ var React = require('React'); -var AlgoliaDocSearch = React.createClass({ - render: function() { +class AlgoliaDocSearch extends React.Component { + render() { return (
); } -}); +} module.exports = AlgoliaDocSearch; diff --git a/website/core/BlogPost.js b/website/core/BlogPost.js index 432fc9617..50ba3d561 100644 --- a/website/core/BlogPost.js +++ b/website/core/BlogPost.js @@ -17,8 +17,8 @@ var BlogPostHeader = require('BlogPostHeader'); var BlogPostFooter = require('BlogPostFooter'); var ExcerptLink = require('ExcerptLink'); -var BlogPost = React.createClass({ - render: function() { +class BlogPost extends React.Component { + render() { var post = this.props.post; return ( @@ -31,6 +31,6 @@ var BlogPost = React.createClass({ ); } -}); +} module.exports = BlogPost; diff --git a/website/core/BlogPostDate.js b/website/core/BlogPostDate.js index 7dd4d9d85..f2a6b2c9e 100644 --- a/website/core/BlogPostDate.js +++ b/website/core/BlogPostDate.js @@ -13,8 +13,8 @@ var React = require('React'); -var BlogPostDate = React.createClass({ - render: function() { +class BlogPostDate extends React.Component { + render() { var post = this.props.post; var match = post.publishedAt.match(/([0-9]+)-([0-9]+)-([0-9]+)/); @@ -32,6 +32,6 @@ var BlogPostDate = React.createClass({ ); } -}); +} module.exports = BlogPostDate; diff --git a/website/core/BlogPostExcerpt.js b/website/core/BlogPostExcerpt.js index 3f5c5b2d6..644a73435 100644 --- a/website/core/BlogPostExcerpt.js +++ b/website/core/BlogPostExcerpt.js @@ -16,8 +16,8 @@ var BlogPostHeader = require('BlogPostHeader'); var Marked = require('Marked'); var ExcerptLink = require('ExcerptLink'); -var BlogPostExcerpt = React.createClass({ - render: function() { +class BlogPostExcerpt extends React.Component { + render() { var post = this.props.post; return (
@@ -33,6 +33,6 @@ var BlogPostExcerpt = React.createClass({
); } -}); +} module.exports = BlogPostExcerpt; diff --git a/website/core/BlogPostFooter.js b/website/core/BlogPostFooter.js index a0be8ecf4..dbfdd421a 100644 --- a/website/core/BlogPostFooter.js +++ b/website/core/BlogPostFooter.js @@ -14,8 +14,8 @@ var React = require('React'); var BlogPostDate = require('BlogPostDate'); -var BlogPostFooter = React.createClass({ - render: function() { +class BlogPostFooter extends React.Component { + render() { var post = this.props.post; var authorImage = this.props.post.authorImage ? this.props.post.authorImage : '/react-native/img/author.png'; @@ -58,6 +58,6 @@ var BlogPostFooter = React.createClass({ ); } -}); +} module.exports = BlogPostFooter; diff --git a/website/core/BlogPostHeader.js b/website/core/BlogPostHeader.js index 53308c237..a275d0de7 100644 --- a/website/core/BlogPostHeader.js +++ b/website/core/BlogPostHeader.js @@ -14,8 +14,8 @@ var React = require('React'); var BlogPostDate = require('BlogPostDate'); -var BlogPostHeader = React.createClass({ - render: function() { +class BlogPostHeader extends React.Component { + render() { var post = this.props.post; var hero; @@ -54,6 +54,6 @@ var BlogPostHeader = React.createClass({ ); } -}); +} module.exports = BlogPostHeader; diff --git a/website/core/DocsSidebar.js b/website/core/DocsSidebar.js index dd0d5f878..dc196d233 100644 --- a/website/core/DocsSidebar.js +++ b/website/core/DocsSidebar.js @@ -13,8 +13,15 @@ var Metadata = require('Metadata'); var React = require('React'); -var DocsSidebar = React.createClass({ - getCategories: function() { +class DocsSidebar extends React.Component { + constructor(props, context) { + super(props, context); + + this.getCategories = this.getCategories.bind(this); + this.getLink = this.getLink.bind(this); + } + + getCategories() { var metadatas = Metadata.files.filter(function(metadata) { return metadata.layout === 'docs' || metadata.layout === 'autodocs'; }); @@ -67,13 +74,13 @@ var DocsSidebar = React.createClass({ categories.push(currentCategory); return categories; - }, + } - getLink: function(metadata) { + getLink(metadata) { return metadata.permalink; - }, + } - render: function() { + render() { return
{this.getCategories().map((category) => @@ -97,6 +104,6 @@ var DocsSidebar = React.createClass({
; } -}); +} module.exports = DocsSidebar; diff --git a/website/core/EjectBanner.js b/website/core/EjectBanner.js index 7a5c05c1b..41af8fccd 100644 --- a/website/core/EjectBanner.js +++ b/website/core/EjectBanner.js @@ -12,8 +12,8 @@ var React = require('React'); -var EjectBanner = React.createClass({ - render: function() { +class EjectBanner extends React.Component { + render() { return (

Project with Native Code Required

@@ -25,6 +25,6 @@ var EjectBanner = React.createClass({
); } -}); +} module.exports = EjectBanner; diff --git a/website/core/ExcerptLink.js b/website/core/ExcerptLink.js index 7a0ab14f7..b167bd8be 100644 --- a/website/core/ExcerptLink.js +++ b/website/core/ExcerptLink.js @@ -13,8 +13,8 @@ var React = require('React'); -var ExcerptLink = React.createClass({ - render: function() { +class ExcerptLink extends React.Component { + render() { var cta = "Read more"; if (this.props.category === "videos") { @@ -29,6 +29,6 @@ var ExcerptLink = React.createClass({ ); } -}); +} module.exports = ExcerptLink; diff --git a/website/core/Footer.js b/website/core/Footer.js index 7220e7ea3..b1e2ceac5 100644 --- a/website/core/Footer.js +++ b/website/core/Footer.js @@ -16,14 +16,14 @@ function getGitHubPath(path) { return 'https://github.com/facebook/react-native/blob/master/' + path; } -var Footer = React.createClass({ - render: function() { +class Footer extends React.Component { + render() { return (

You can edit the content above on GitHub and send us a pull request!

); } -}); +} module.exports = Footer; diff --git a/website/core/H2.js b/website/core/H2.js index 893a5508b..a19de1519 100644 --- a/website/core/H2.js +++ b/website/core/H2.js @@ -13,10 +13,10 @@ var Header = require('Header'); var React = require('React'); -var H2 = React.createClass({ - render: function() { +class H2 extends React.Component { + render() { return
{this.props.children}
; } -}); +} module.exports = H2; diff --git a/website/core/Header.js b/website/core/Header.js index 6b68a96f7..4f78a0f48 100644 --- a/website/core/Header.js +++ b/website/core/Header.js @@ -16,12 +16,8 @@ var PropTypes = require('prop-types'); var slugify = require('slugify'); -var Header = React.createClass({ - contextTypes: { - permalink: PropTypes.string - }, - - render: function() { +class Header extends React.Component { + render() { var slug = slugify(this.props.toSlug || this.props.children); var H = 'h' + this.props.level; var base = this.context.permalink || ''; @@ -33,6 +29,10 @@ var Header = React.createClass({ ); } -}); +} + +Header.contextTypes = { + permalink: PropTypes.string +}; module.exports = Header; diff --git a/website/core/HeaderLinks.js b/website/core/HeaderLinks.js index 50bf78f4b..7b38f8d66 100644 --- a/website/core/HeaderLinks.js +++ b/website/core/HeaderLinks.js @@ -13,18 +13,19 @@ var AlgoliaDocSearch = require('AlgoliaDocSearch'); var React = require('React'); -var HeaderLinks = React.createClass({ - linksInternal: [ - {section: 'docs', href: 'docs/getting-started.html', text: 'Docs', target: '.nav-docs'}, - {section: 'support', href: '/react-native/support.html', text: 'Help'}, - {section: 'blog', href: '/react-native/blog/', text: 'Blog'}, - ], - linksExternal: [ - {section: 'github', href: 'https://github.com/facebook/react-native', text: 'GitHub'}, - {section: 'react', href: 'http://facebook.github.io/react', text: 'React'}, - ], +var linksInternal = [ + {section: 'docs', href: 'docs/getting-started.html', text: 'Docs', target: '.nav-docs'}, + {section: 'support', href: '/react-native/support.html', text: 'Help'}, + {section: 'blog', href: '/react-native/blog/', text: 'Blog'}, +]; - makeLinks: function(links) { +var linksExternal = [ + {section: 'github', href: 'https://github.com/facebook/react-native', text: 'GitHub'}, + {section: 'react', href: 'http://facebook.github.io/react', text: 'React'}, +]; + +class HeaderLinks extends React.Component { + makeLinks(links) { return links.map(function(link) { return (
  • @@ -37,23 +38,23 @@ var HeaderLinks = React.createClass({
  • ); }, this); - }, + } - render: function() { + render() { return (
    ); } -}); +} module.exports = HeaderLinks; diff --git a/website/core/HeaderWithGithub.js b/website/core/HeaderWithGithub.js index 9588d3799..e64c6cefd 100644 --- a/website/core/HeaderWithGithub.js +++ b/website/core/HeaderWithGithub.js @@ -19,13 +19,8 @@ function getGitHubPath(path) { return 'https://github.com/facebook/react-native/blob/master/' + path; } -var HeaderWithGithub = React.createClass({ - - contextTypes: { - version: PropTypes.string - }, - - render: function() { +class HeaderWithGithub extends React.Component { + render() { return ( @@ -47,6 +42,10 @@ var HeaderWithGithub = React.createClass({
    ); } -}); +} + +HeaderWithGithub.contextTypes = { + version: PropTypes.string +}; module.exports = HeaderWithGithub; diff --git a/website/core/Hero.js b/website/core/Hero.js index 79463ce46..9c4fa4c94 100644 --- a/website/core/Hero.js +++ b/website/core/Hero.js @@ -12,8 +12,8 @@ var React = require('React'); -var Hero = React.createClass({ - render: function() { +class Hero extends React.Component { + render() { return (
    @@ -26,6 +26,6 @@ var Hero = React.createClass({
    ); } -}); +} module.exports = Hero; diff --git a/website/core/Marked.js b/website/core/Marked.js index d105e1f30..82b2d297b 100644 --- a/website/core/Marked.js +++ b/website/core/Marked.js @@ -1193,15 +1193,15 @@ marked.inlineLexer = InlineLexer.output; marked.parse = marked; -var Marked = React.createClass({ - render: function() { +class Marked extends React.Component { + render() { return this.props.children ? React.DOM.div( null, marked(this.props.children, this.props) ) : null; - }, -}); + } +} module.exports = Marked; diff --git a/website/core/Prism.js b/website/core/Prism.js index 6662ecaa3..ed9697fd3 100644 --- a/website/core/Prism.js +++ b/website/core/Prism.js @@ -526,16 +526,8 @@ _.languages.java = _.languages.extend('clike', { }, }); -var Prism = React.createClass({ - statics: { - _: _, - }, - getDefaultProps: function() { - return { - language: 'javascript', - }; - }, - render: function() { +class Prism extends React.Component { + render() { var grammar = _.languages[this.props.language]; if (!grammar) { grammar = _.languages.javascript; @@ -549,7 +541,12 @@ var Prism = React.createClass({ )}
    ); - }, -}); + } +} + +Prism._ = _; +Prism.defaultProps = { + language: 'javascript', +}; module.exports = Prism; diff --git a/website/core/ShowcaseAppIcon.js b/website/core/ShowcaseAppIcon.js index fdad755ef..7ecafa908 100644 --- a/website/core/ShowcaseAppIcon.js +++ b/website/core/ShowcaseAppIcon.js @@ -13,14 +13,14 @@ var React = require('React'); -const ShowcaseAppIcon = React.createClass({ - render: function() { +class ShowcaseAppIcon extends React.Component { + render() { return ( {this.props.name} ); } -}); +} module.exports = ShowcaseAppIcon; diff --git a/website/core/Site.js b/website/core/Site.js index 8302e9284..c6721e211 100644 --- a/website/core/Site.js +++ b/website/core/Site.js @@ -14,8 +14,8 @@ var HeaderLinks = require('HeaderLinks'); var Metadata = require('Metadata'); var React = require('React'); -var Site = React.createClass({ - render: function() { +class Site extends React.Component { + render() { const path = Metadata.config.RN_DEPLOYMENT_PATH; const version = Metadata.config.RN_VERSION; const algoliaVersion = version === 'next' @@ -426,6 +426,7 @@ var Site = React.createClass({ ); - }, -}); + } +} + module.exports = Site; diff --git a/website/core/SnackPlayer.js b/website/core/SnackPlayer.js index f21acdad9..270b277fa 100644 --- a/website/core/SnackPlayer.js +++ b/website/core/SnackPlayer.js @@ -41,14 +41,16 @@ var ReactNativeToExpoSDKVersionMap = { * } * ``` */ -var SnackPlayer = React.createClass({ - contextTypes: { - version: PropTypes.number.isRequired, - }, +class SnackPlayer extends React.Component { + constructor(props, context) { + super(props, context); + + this.parseParams = this.parseParams.bind(this); + } componentDidMount() { window.ExpoSnack && window.ExpoSnack.initialize(); - }, + } render() { var code = encodeURIComponent(this.props.children); @@ -110,9 +112,9 @@ var SnackPlayer = React.createClass({ ); - }, + } - parseParams: function(paramString) { + parseParams(paramString) { var params = {}; if (paramString) { @@ -124,7 +126,11 @@ var SnackPlayer = React.createClass({ } return params; - }, -}); + } +} + +SnackPlayer.contextTypes = { + version: PropTypes.number.isRequired, +}; module.exports = SnackPlayer; diff --git a/website/core/WebPlayer.js b/website/core/WebPlayer.js index 38719fdc5..c18fa29fb 100644 --- a/website/core/WebPlayer.js +++ b/website/core/WebPlayer.js @@ -31,8 +31,14 @@ var WEB_PLAYER_VERSION = '1.2.6'; * AppRegistry.registerComponent('MyApp', () => App); * ``` */ -var WebPlayer = React.createClass({ - parseParams: function(paramString) { +class WebPlayer extends React.Component { + constructor(props, context) { + super(props, context); + + this.parseParams = this.parseParams.bind(this); + } + + parseParams(paramString) { var params = {}; if (paramString) { @@ -44,9 +50,9 @@ var WebPlayer = React.createClass({ } return params; - }, + } - render: function() { + render() { var hash = `#code=${encodeURIComponent(this.props.children)}`; if (this.props.params) { @@ -65,7 +71,7 @@ var WebPlayer = React.createClass({ /> ); - }, -}); + } +} module.exports = WebPlayer; diff --git a/website/core/center.js b/website/core/center.js index e6aaffbbc..f070658b0 100644 --- a/website/core/center.js +++ b/website/core/center.js @@ -12,14 +12,14 @@ var React = require('React'); -var center = React.createClass({ - render: function() { +class center extends React.Component { + render() { return (
    {this.props.children}
    ); } -}); +} module.exports = center; diff --git a/website/layout/AutodocsLayout.js b/website/layout/AutodocsLayout.js index 3ff6e7dbe..bc0f1da66 100644 --- a/website/layout/AutodocsLayout.js +++ b/website/layout/AutodocsLayout.js @@ -14,7 +14,6 @@ var DocsSidebar = require('DocsSidebar'); var Footer = require('Footer'); var Header = require('Header'); -var HeaderWithGithub = require('HeaderWithGithub'); var Marked = require('Marked'); var Metadata = require('Metadata'); var Prism = require('Prism'); @@ -204,8 +203,23 @@ function getNamedTypes(typedefs) { return namedTypes; } -var ComponentDoc = React.createClass({ - renderProp: function(name, prop) { +class ComponentDoc extends React.Component { + constructor(props, context) { + super(props, context); + + this.extractPlatformFromProps = this.extractPlatformFromProps.bind(this); + this.renderCompose = this.renderCompose.bind(this); + this.renderStylesheetProp = this.renderStylesheetProp.bind(this); + this.renderStylesheetProps = this.renderStylesheetProps.bind(this); + this.renderMethod = this.renderMethod.bind(this); + this.renderMethods = this.renderMethods.bind(this); + this.renderProp = this.renderProp.bind(this); + this.renderProps = this.renderProps.bind(this); + this.renderTypeDef = this.renderTypeDef.bind(this); + this.renderTypeDefs = this.renderTypeDefs.bind(this); + } + + renderProp(name, prop) { return (
    @@ -232,9 +246,9 @@ var ComponentDoc = React.createClass({ {prop.description && {prop.description}}
    ); - }, + } - renderCompose: function(name) { + renderCompose(name) { return (
    @@ -242,9 +256,9 @@ var ComponentDoc = React.createClass({
    ); - }, + } - renderStylesheetProp: function(name, prop) { + renderStylesheetProp(name, prop) { return (
    @@ -261,9 +275,9 @@ var ComponentDoc = React.createClass({
    ); - }, + } - renderStylesheetProps: function(stylesheetName) { + renderStylesheetProps(stylesheetName) { var style = this.props.content.styles[stylesheetName]; this.extractPlatformFromProps(style.props); return ( @@ -299,9 +313,9 @@ var ComponentDoc = React.createClass({ } ); - }, + } - renderProps: function(props, composes) { + renderProps(props, composes) { return (
    {(composes || []).map((name) => @@ -313,9 +327,9 @@ var ComponentDoc = React.createClass({ }
    ); - }, + } - extractPlatformFromProps: function(props) { + extractPlatformFromProps(props) { for (var key in props) { var prop = props[key]; var description = prop.description || ''; @@ -326,9 +340,9 @@ var ComponentDoc = React.createClass({ prop.description = description; prop.platforms = platforms; } - }, + } - renderMethod: function(method, namedTypes) { + renderMethod(method, namedTypes) { return ( ); - }, + } - renderMethods: function(methods, namedTypes) { + renderMethods(methods, namedTypes) { if (!methods || !methods.length) { return null; } @@ -357,9 +371,9 @@ var ComponentDoc = React.createClass({ ); - }, + } - renderTypeDef: function(typedef, namedTypes) { + renderTypeDef(typedef, namedTypes) { return ( ); - }, + } - renderTypeDefs: function(typedefs, namedTypes) { + renderTypeDefs(typedefs, namedTypes) { if (!typedefs || !typedefs.length) { return null; } @@ -388,9 +402,9 @@ var ComponentDoc = React.createClass({ ); - }, + } - render: function() { + render() { var content = this.props.content; this.extractPlatformFromProps(content.props); const namedTypes = getNamedTypes(content.typedef); @@ -406,11 +420,23 @@ var ComponentDoc = React.createClass({ ); } -}); +} -var APIDoc = React.createClass({ +class APIDoc extends React.Component { + constructor(props, context) { + super(props, context); - renderMethod: function(method, namedTypes) { + this.renderMethod = this.renderMethod.bind(this); + this.renderMethods = this.renderMethods.bind(this); + this.renderProperty = this.renderProperty.bind(this); + this.renderProperties = this.renderProperties.bind(this); + this.renderClasses = this.renderClasses.bind(this); + this.renderTypeDef = this.renderTypeDef.bind(this); + this.renderTypeDefs = this.renderTypeDefs.bind(this); + this.renderMainDescription = this.renderMainDescription.bind(this); + } + + renderMethod(method, namedTypes) { return ( ); - }, + } - renderMethods: function(methods, namedTypes) { + renderMethods(methods, namedTypes) { if (!methods.length) { return null; } @@ -439,9 +465,9 @@ var APIDoc = React.createClass({ ); - }, + } - renderProperty: function(property) { + renderProperty(property) { return (
    @@ -457,9 +483,9 @@ var APIDoc = React.createClass({ }
    ); - }, + } - renderProperties: function(properties) { + renderProperties(properties) { if (!properties || !properties.length) { return null; } @@ -473,9 +499,9 @@ var APIDoc = React.createClass({ ); - }, + } - renderClasses: function(classes, namedTypes) { + renderClasses(classes, namedTypes) { if (!classes || !classes.length) { return null; } @@ -503,9 +529,9 @@ var APIDoc = React.createClass({ ); - }, + } - renderTypeDef: function(typedef, namedTypes) { + renderTypeDef(typedef, namedTypes) { return ( ); - }, + } - renderTypeDefs: function(typedefs, namedTypes) { + renderTypeDefs(typedefs, namedTypes) { if (!typedefs || !typedefs.length) { return null; } @@ -534,9 +560,9 @@ var APIDoc = React.createClass({ ); - }, + }; - renderMainDescription: function(content) { + renderMainDescription(content) { if (content.docblock) { return ( @@ -552,9 +578,9 @@ var APIDoc = React.createClass({ ); } return null; - }, + } - render: function() { + render() { var content = this.props.content; if (!content.methods) { throw new Error( @@ -572,10 +598,18 @@ var APIDoc = React.createClass({ ); } -}); +} -var Method = React.createClass({ - renderTypehintRec: function(typehint) { +class Method extends React.Component { + constructor(props, context) { + super(props, context); + + this.renderTypehint = this.renderTypehint.bind(this); + this.renderTypehintRec = this.renderTypehintRec.bind(this); + this.renderMethodExamples = this.renderMethodExamples.bind(this); + this.renderMethodParameters = this.renderMethodParameters.bind(this); + } + renderTypehintRec(typehint) { if (typehint.type === 'simple') { return typehint.value; } @@ -585,10 +619,9 @@ var Method = React.createClass({ } return JSON.stringify(typehint); + } - }, - - renderTypehint: function(typehint) { + renderTypehint(typehint) { if (typeof typehint === 'object' && typehint.name) { return renderType(typehint); } @@ -599,9 +632,9 @@ var Method = React.createClass({ } return this.renderTypehintRec(typehint); - }, + } - renderMethodExamples: function(examples) { + renderMethodExamples(examples) { if (!examples || !examples.length) { return null; } @@ -621,9 +654,9 @@ var Method = React.createClass({ ); }); - }, + }; - renderMethodParameters: function(params) { + renderMethodParameters(params) { if (!params || !params.length) { return null; } @@ -661,9 +694,9 @@ var Method = React.createClass({ ); - }, + } - render: function() { + render() { return (
    @@ -690,11 +723,18 @@ var Method = React.createClass({ {this.renderMethodExamples(this.props.examples)}
    ); - }, -}); + } +} -var TypeDef = React.createClass({ - renderProperties: function(properties) { +class TypeDef extends React.Component { + constructor(props, context) { + super(props, context); + + this.renderProperties = this.renderProperties.bind(this); + this.renderValues = this.renderValues.bind(this); + } + + renderProperties(properties) { if (!properties || !properties.length) { return null; } @@ -729,9 +769,9 @@ var TypeDef = React.createClass({ ); - }, + } - renderValues: function(values) { + renderValues(values) { if (!values || !values.length) { return null; } @@ -764,9 +804,9 @@ var TypeDef = React.createClass({ ); - }, + } - render: function() { + render() { return (
    @@ -782,23 +822,24 @@ var TypeDef = React.createClass({ {this.renderValues(this.props.values)}
    ); - }, -}); + } +} -var Autodocs = React.createClass({ - childContextTypes: { - permalink: PropTypes.string, - version: PropTypes.string - }, +class Autodocs extends React.Component { + contsructor(props, context) { + super(props, context); - getChildContext: function() { + this.renderFullDescription = this.renderFullDescription.bind(this); + } + + getChildContext() { return { permalink: this.props.metadata.permalink, version: Metadata.config.RN_VERSION || 'next' }; - }, + } - renderFullDescription: function(docs) { + renderFullDescription(docs) { if (!docs.fullDescription) { return; } @@ -811,9 +852,9 @@ var Autodocs = React.createClass({