Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yulian47 #3451

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import React from 'react';
import './App.scss';
import { Sum } from './components/Sum/Sum';

export const App = () => (
<>
<p>Sum of 2 and 3 is 5</p>
<p>Sum of -5 and 5 is 0</p>
<p>Sum of 10 and 0 is 10</p>
<p>Sum of 0 and 5 is 5</p>
<p>Sum of 0 and 0 is 0</p>
{/* Replace paragraphs with Sum componets */}
{/* And remove commented lines :) */}
</>
);
const App = () => {
return (
<div>
<Sum a={2} b={3} />
<Sum a={-5} b={5} />
<Sum a={10} />
<Sum b={5} />
<Sum />
</div>
);
};

export default App;
21 changes: 20 additions & 1 deletion src/components/Sum/Sum.jsx
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
// export const Sum = () => ();
import React from 'react';
import PropTypes from 'prop-types';

Check failure on line 2 in src/components/Sum/Sum.jsx

View workflow job for this annotation

GitHub Actions / run_linter (20.x)

'prop-types' should be listed in the project's dependencies. Run 'npm i -S prop-types' to add it

export const Sum = ({ a, b }) => {
return (
<p>
Sum of {a} and {b} is {a + b}
</p>
);
};

Sum.propTypes = {
a: PropTypes.number,
b: PropTypes.number,
};

Sum.defaultProps = {
a: 0,
b: 0,
};
7 changes: 5 additions & 2 deletions src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';

import { App } from './App';
const container = document.getElementById('root');
const root = createRoot(container);

createRoot(document.getElementById('root')).render(<App />);
root.render(<App />);
Loading