feat(webpack-react): install and add prop-types.js example

This commit is contained in:
dancingCycle 2022-06-07 11:19:58 +02:00
parent 63c89e072a
commit 123ac80de7
5 changed files with 33 additions and 8 deletions

View File

@ -26,6 +26,7 @@
"webpack-dev-server": "^4.9.2"
},
"dependencies": {
"prop-types": "^15.8.1",
"react": "^18.1.0",
"react-dom": "^18.1.0"
}

View File

@ -0,0 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
//destructure props
const Hello = ({msg}) => {
return (
<>
<div>{msg}</div>
</>
);
}
export default Hello
Hello.propTypes = {
msg: PropTypes.string,
};

View File

@ -1,7 +0,0 @@
import React from 'react';
const Home = () => {
return <div>React.js Lambda Function Component</div>
}
export default Home

View File

@ -1,6 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Home from './components/home';
import Home from './pages/home';
//since react 18
import { createRoot } from 'react-dom/client';

View File

@ -0,0 +1,14 @@
import React from 'react';
import Hello from '../components/hello';
const Home = () => {
return (
<>
<h1>Home</h1>
<h2>(React.js Lambda Function Component)</h2>
<Hello msg="Hello World!" />
</>
);
}
export default Home