<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Bridge.React
{
	public abstract class StatelessComponent<TProps>
	{
		private static Dictionary<Type, Func<TProps, ReactElement>> _reactStatelessRenderFunctions = new Dictionary<Type, Func<TProps, ReactElement>>();
		private readonly ReactElement _reactElement;
		protected StatelessComponent(TProps props, params Union<ReactElement, string>[] children)
		{
			if (children != null)
			{
				if (children.Any(element => element == null))
					throw new ArgumentException("Null reference encountered in children set");
			}

			// When preparing the "_reactStatelessRenderFunction" reference, a local "reactStatelessRenderFunction" alias is used - this is just so that the JavaScript
			// code further down (which calls React.createElement) can use this local alias and not have to know how Bridge stores static references.
			Func<TProps, ReactElement> reactStatelessRenderFunction;
			var currentType = ((object)this).GetType(); // Cast to object first in case derived class uses [IgnoreGeneric] - see http://forums.bridge.net/forum/bridge-net-pro/bugs/3343
			if (!_reactStatelessRenderFunctions.TryGetValue(currentType, out reactStatelessRenderFunction))
			{
				reactStatelessRenderFunction = CreateStatelessRenderFunction();
				_reactStatelessRenderFunctions[currentType] = reactStatelessRenderFunction;
			}

			// When we pass the props reference to React.createElement, React's internals will rip it apart and reform it - which will cause problems if TProps is a
			// class with property getters and setters (or any other function) defined on the prototype, since members from the class prototype are not maintained<commit_msg>Change StatelessComponent to allow any child to be null as React itself does<commit_after>﻿using System;
using System.Collections.Generic;

namespace Bridge.React
{
	public abstract class StatelessComponent<TProps>
	{
		private static Dictionary<Type, Func<TProps, ReactElement>> _reactStatelessRenderFunctions = new Dictionary<Type, Func<TProps, ReactElement>>();
		private readonly ReactElement _reactElement;
		protected StatelessComponent(TProps props, params Union<ReactElement, string>[] children)
		{
			// When preparing the "_reactStatelessRenderFunction" reference, a local "reactStatelessRenderFunction" alias is used - this is just so that the JavaScript
			// code further down (which calls React.createElement) can use this local alias and not have to know how Bridge stores static references.
			Func<TProps, ReactElement> reactStatelessRenderFunction;
			var currentType = ((object)this).GetType(); // Cast to object first in case derived class uses [IgnoreGeneric] - see http://forums.bridge.net/forum/bridge-net-pro/bugs/3343
			if (!_reactStatelessRenderFunctions.TryGetValue(currentType, out reactStatelessRenderFunction))
			{
				reactStatelessRenderFunction = CreateStatelessRenderFunction();
				_reactStatelessRenderFunctions[currentType] = reactStatelessRenderFunction;
			}

			// When we pass the props reference to React.createElement, React's internals will rip it apart and reform it - which will cause problems if TProps is a
			// class with property getters and setters (or any other function) defined on the prototype, since members from the class prototype are not maintained
{'fraction_non_alphanumeric': 0.07236842105263158, 'fraction_numerical': 0.0023923444976076554, 'mean_word_length': 5.287593984962406, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7650203', 'n_tokens_mistral': 901, 'n_tokens_neox': 823, 'n_words': 316}