feat(webpack-react): install and add prop-types.js example
This commit is contained in:
parent
63c89e072a
commit
123ac80de7
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
};
|
|
@ -1,7 +0,0 @@
|
|||
import React from 'react';
|
||||
|
||||
const Home = () => {
|
||||
return <div>React.js Lambda Function Component</div>
|
||||
}
|
||||
|
||||
export default Home
|
|
@ -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';
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue