I have a react class like this ..
class Questions extends React.Component {
decodestr(decstr){
var newstr = Base64.decode(decstr);
return newstr;
}
render() {
return(
<div className="questions">
{this.decodestr(this.props.cont)}
</div>
)
}
}
I am trying to display decoded content inside a div like shown below :
<div> <span> <b>Questions Regulatory:</b></span> <span>{source.questions_regulatory}</span> </div>
where {source.questions_regulatory} is the encoded content.. How can I print the decoded content here.. Now am getting an error like this : ReferenceError: Base64 is not defined
I installed Base64 using npm install Base64 --save.
This is my webpack config ;
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
devtool:"eval",
context:path.join(__dirname),
entry: [
'webpack-hot-middleware/client?reload=true',
'./src/index.jsx'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
],
resolve: {
alias: {
react: path.resolve('./node_modules/react')
},
extensions:[".js", ".jsx", ".webpack.js", ".web.js",""]
},
resolveLoader: {
root: path.join(__dirname, "node_modules")
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
loader: 'babel',
query: {
presets: [
require.resolve('babel-preset-es2015'),
require.resolve('babel-preset-react')
]
}
},
{
test: /\.scss$/,
loaders: ["style", "css", "sass"]
},
{
test: /\.(jpg|png|svg)$/,
loaders: [
'file-loader?name=[path][name].[ext]'
]
}
]
}
};
Not sure how to use this React class for rendering the decoded content..Also not sure why I get a refernce error...Any help appreciated...