Just want to see the code? Check out the sample project.
React Helmet is a library that allows setting elements inside the <head>
tag from anywhere in the render tree.
Make sure ReactJS.NET is up to date. You will need at least ReactJS.NET 4.0 (which is in public beta at the time of writing).
Expose React Helmet in your server bundle:
import Helmet from 'react-helmet';
global.Helmet = Helmet;
Add the render helper to the call to Html.React
:
@using React.AspNet
@using React.RenderFunctions
@{
var helmetFunctions = new ReactHelmetFunctions();
}
@Html.React("RootComponent", new { exampleProp = "a" }, renderFunctions: new ChainedRenderFunctions(helmetFunctions))
@{
ViewBag.HelmetTitle = helmetFunctions.RenderedHelmet.GetValueOrDefault("title");
}
In your layout file, render the helmet title that is now in the ViewBag:
<!DOCTYPE html>
<html>
<head>
@Html.Raw(ViewBag.HelmetTitle)
<meta charset="utf-8" />
@Html.Raw(ViewBag.ServerStyles)
</head>
<body>
@RenderBody()
</body>
</html>
男性内分泌失调有什么症状hcv8jop6ns2r.cn | 闫和阎有什么区别hcv8jop3ns2r.cn | 小孩爱吃手指头是什么原因hcv9jop7ns1r.cn | 脸上长癣用什么药膏hcv8jop8ns8r.cn | RH阳性什么意思hcv8jop2ns5r.cn |
gpa什么意思hcv9jop4ns0r.cn | usd什么意思hcv7jop6ns7r.cn | 蝼蛄是什么onlinewuye.com | 梦到捡金子首饰是什么意思hcv9jop1ns1r.cn | 心悸吃什么药xscnpatent.com |
化疗后恶心呕吐吃什么可以缓解imcecn.com | rh因子阳性是什么意思xinmaowt.com | 6.10号是什么星座hcv9jop5ns5r.cn | parzin眼镜是什么牌子hcv8jop9ns2r.cn | 打了麻药有什么副作用hcv8jop5ns5r.cn |
炖猪排骨放什么调料hcv8jop7ns6r.cn | 两鬓斑白是什么意思hcv8jop0ns6r.cn | cph是什么意思0735v.com | 淀粉在超市里叫什么xianpinbao.com | 纸鸢是什么意思hcv7jop7ns2r.cn |