Is there a way to export react component as function and pass in props as params of the function in non-react project?
I am recently finished a react project with create-react-app. Now i wanted to use it to other non-react project(pure Javascript + html, Angular etc).
However, since these projects can not just use the component in React fashion(composition). I am wondering if we can export react component as function, so we can just use it across different projects without worrying about react's architect.
For instance:
export default class MyComponent extends React.Component{
render(){
return(
<div>
{"Hello World" + this.prop.name}
</div>
)
}
}
And then export it as function. So in the non-react project, i can do something like this:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Non-React App</title>
</head>
<script src="https://mydisk/ImportMyReact.js" ></script>
<script>
MyComponent("Jake")
</script>
<body>
</body>
</html>
I tried to use webpack to bundle it, but I have no luck because the bundle.js is a giant piece of code that I cant just import certain function out of it.