Skip to content

Commit 87e2ca7

Browse files
committed
Use ES6 transforms in sample
1 parent f3fe518 commit 87e2ca7

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

Diff for: src/React.Sample.Mvc4/App_Start/ReactConfig.cs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public static class ReactConfig
1616
public static void Configure()
1717
{
1818
ReactSiteConfiguration.Configuration
19+
.SetUseHarmony(true)
1920
.AddScript("~/Content/Sample.jsx");
2021
}
2122
}

Diff for: src/React.Sample.Mvc4/Content/Sample.jsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ var CommentsBox = React.createClass({
1414
initialComments: React.PropTypes.array.isRequired,
1515
commentsPerPage: React.PropTypes.number.isRequired
1616
},
17-
getInitialState: function() {
17+
getInitialState() {
1818
return {
1919
comments: this.props.initialComments,
2020
page: 1,
2121
hasMore: true,
2222
loadingMore: false
2323
};
2424
},
25-
loadMoreClicked: function(evt) {
25+
loadMoreClicked(evt) {
2626
var nextPage = this.state.page + 1;
2727
this.setState({
2828
page: nextPage,
@@ -43,7 +43,7 @@ var CommentsBox = React.createClass({
4343
xhr.send();
4444
return false;
4545
},
46-
render: function() {
46+
render() {
4747
var commentNodes = this.state.comments.map(function (comment) {
4848
return <Comment author={comment.Author}>{comment.Text}</Comment>;
4949
});
@@ -58,7 +58,7 @@ var CommentsBox = React.createClass({
5858
</div>
5959
);
6060
},
61-
renderMoreLink: function() {
61+
renderMoreLink() {
6262
if (this.state.loadingMore) {
6363
return <em>Loading...</em>;
6464
} else if (this.state.hasMore) {
@@ -77,7 +77,7 @@ var Comment = React.createClass({
7777
propTypes: {
7878
author: React.PropTypes.object.isRequired
7979
},
80-
render: function() {
80+
render() {
8181
return (
8282
<li>
8383
<Avatar author={this.props.author} />
@@ -92,7 +92,7 @@ var Avatar = React.createClass({
9292
propTypes: {
9393
author: React.PropTypes.object.isRequired
9494
},
95-
render: function() {
95+
render() {
9696
return (
9797
<img
9898
src={this.getPhotoUrl(this.props.author)}
@@ -103,7 +103,7 @@ var Avatar = React.createClass({
103103
/>
104104
);
105105
},
106-
getPhotoUrl: function(author) {
106+
getPhotoUrl(author) {
107107
return 'http://graph.facebook.com/' + author.Facebook + '/picture';
108108
}
109109
});

Diff for: src/React.Sample.Mvc4/TransformJsx.proj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="TransformJsx">
33
<UsingTask AssemblyFile="..\..\bin\$(Configuration)\React.MSBuild\React.MSBuild.dll" TaskName="TransformJsx" />
44
<Target Name="TransformJsx">
5-
<TransformJsx SourceDir="$(MSBuildProjectDirectory)" />
5+
<TransformJsx SourceDir="$(MSBuildProjectDirectory)" UseHarmony="true" />
66
</Target>
77
</Project>

Diff for: src/React/IReactSiteConfiguration.cs

+5
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,10 @@ public interface IReactSiteConfiguration
3737
/// </summary>
3838
/// <returns><c>true</c> if support for es6 syntax should be rewritten.</returns>
3939
bool UseHarmony { get; set; }
40+
41+
/// <summary>
42+
/// Specifies whether ES6 (harmony) syntax should be transformed
43+
/// </summary>
44+
IReactSiteConfiguration SetUseHarmony(bool useHarmony);
4045
}
4146
}

Diff for: src/React/ReactSiteConfiguration.cs

+9
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,14 @@ public IList<string> Scripts
6363
/// </summary>
6464
/// <returns><c>true</c> if support for es6 syntax should be rewritten.</returns>
6565
public bool UseHarmony { get; set; }
66+
67+
/// <summary>
68+
/// Specifies whether ES6 (harmony) syntax should be transformed
69+
/// </summary>
70+
public IReactSiteConfiguration SetUseHarmony(bool useHarmony)
71+
{
72+
UseHarmony = useHarmony;
73+
return this;
74+
}
6675
}
6776
}

0 commit comments

Comments
 (0)