Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display ReactElement in dimensions. #54

Open
Distil62 opened this issue Jun 16, 2017 · 2 comments
Open

Display ReactElement in dimensions. #54

Distil62 opened this issue Jun 16, 2017 · 2 comments

Comments

@Distil62
Copy link

Hello,

I'm trying to display a React Element in my dimension row but it don't work.
Like that

var dimensions = 
[
		{ title: "Type de gravier", value: function (row) { return row.data.materialName } },
		{
			title: "état", value: function (row) {
				var res;
				if (row.data.state == "good") {
					res = React.createElement("div", {className: "1stClass"}, <div></div>)
				}
				else {
					res = React.createElement("div", { className: "2ndClass" }, <div></div>)
				}
				console.log(res);
				return res;
			}
		},
]

how can i do that ?
Thank

@suriya
Copy link
Contributor

suriya commented Dec 26, 2018

In

<span dangerouslySetInnerHTML={{__html: text || ''}}></span> {solo}
changing the code to

<span>{text || ''}</span> {solo}

allows the user to render any react element. Instead of returning a string, the template key in the dimension's specification can return an actual React element.

@davidguttman Is this a change that you would be interested in doing? This would likely be a backwards-incompatible change.

@davidguttman
Copy link
Owner

Yep, this would be great, but I'm pretty sure we could handle both, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants