Created
November 26, 2015 10:04
-
-
Save yandongxu/141cdf5bfa2e23c3c87f to your computer and use it in GitHub Desktop.
React Intl starter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { IntlMixin, FormattedHTMLMessage } from 'react-intl'; | |
const Greeting = React.createClass({ | |
mixins: [IntlMixin], | |
getDefaultProps: function() { | |
return { | |
'messages': { | |
'greeting': 'Hello {name}' | |
} | |
}; | |
}, | |
render: function () { | |
return ( | |
<div> | |
<FormattedHTMLMessage | |
message={this.getIntlMessage('greeting')} | |
name="Annie" | |
content="" /> | |
</div> | |
); | |
} | |
}) | |
module.exports = Greeting; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "react-intl-demo", | |
"version": "0.1.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "node server.js" | |
}, | |
"author": "dongxu <[email protected]>", | |
"license": "ISC", | |
"dependencies": { | |
"intl": "^1.0.1", | |
"react": ">=0.11.2 <0.14.0", | |
"react-intl": "^1.2.2" | |
}, | |
"devDependencies": { | |
"babel-core": "^6.2.1", | |
"babel-loader": "^6.2.0", | |
"babel-preset-es2015": "^6.1.18", | |
"babel-preset-react": "^6.1.18", | |
"webpack": "^1.12.9", | |
"webpack-dev-server": "^1.14.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const webpack = require('webpack'); | |
module.exports = { | |
devtool: 'cheap-module-source-map', | |
entry: [ | |
'webpack-dev-server/client?http://localhost:4000', | |
'webpack/hot/only-dev-server', | |
'./src/index' | |
], | |
output: { | |
path: path.resolve(__dirname, 'dist'), | |
filename: 'bundle.js', | |
publicPath: '/static/' | |
}, | |
plugins: [ | |
new webpack.HotModuleReplacementPlugin() | |
], | |
module: { | |
loaders: [{ | |
test: /\.jsx?$/, | |
loaders: ['babel'], | |
include: path.join(__dirname, 'src'), | |
}] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment