I am implementing a dynamic rendering in React in that I am using syntax like
var Set=require('../../'+RecivedData.Id);
React.render(<CustomComponent inputType={Set} />,document.getElementById("secondCol"));
and my CustomComponent looks like
render: function() {
var InputType=this.props.inputType;
console.log(InputType)
return (
<InputType />
);
},
I just want to know how I can pass the parameters, I mean to say if we use in static mode then we can use below mentioned syntax
var Item=require('../../Item');
React.render(<Item MetaItemName={"Users"} MetaItemId={1} Key={1}/>,document.getElementById("firstCol"));
Same Parameters I have to pass when I am using require dynamic rendering.
so can anyone please let me know the syntax to pass the parameters while using require
You are using CommonJS, which unlike AMD can't be dynamically typed in the browser. This is because the dependencies need to be built in at compilation time, and the paths are relative to where they are required. You will have to do something like this:
Then: