'React - how to add fontsize into React.createElement?
Am a little of a newbie on the block and learning React - I have this segment of a function below:
AlertNotifications.prototype.render = function () {
return (React.createElement("div", null, this.props.alerts.map(function (alert) { return React.createElement(MessageBar, { messageBarType: alert.type === AlertType.Urgent ? MessageBarType.severeWarning : MessageBarType.warning, isMultiline: false },
alert.message,
alert.moreInformationUrl ? React.createElement("a", { href: alert.moreInformationUrl }, strings.MoreInformation) : ''); })));
};
return AlertNotifications;
I need to alter the fontsize of the returned DIV - can you please let me know what I need to alter - or add to the above to alter the fontsize to Arial 16px?
Many thanks in advance
G
Solution 1:[1]
Try to use this one:
React.createElement("div", {
style: {
"font-size": "16px"
}
}, /* Put here what you need to insert in div */)
So, basically, the second attribute in React.createElement is used for attributes.
Solution 2:[2]
You can add a class and style it.
React.createElement('div', {class-here}, .......)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | General Grievance |
Solution 2 | code salley |