-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from arolla/session-introduction-react
Session introduction react
- Loading branch information
Showing
4 changed files
with
65 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React, {ReactNode} from 'react' | ||
|
||
interface Props { | ||
children: ReactNode | ||
} | ||
|
||
const Container = ({children}: Props): JSX.Element => { | ||
return (<div> | ||
{children} | ||
</div>) | ||
} | ||
|
||
export default Container |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
import React from 'react' | ||
import React, { useState } from 'react' | ||
|
||
interface Props { | ||
title: string | ||
url?: string | ||
person: string | ||
} | ||
|
||
const Header = (props: Props): JSX.Element => { | ||
return (<h1> | ||
{props.title} | ||
</h1>) | ||
const { title, person } = props | ||
|
||
const [newTitle, setNewTitle] = useState<string>(title) | ||
|
||
return ( | ||
<> | ||
<h1 onClick={() => {setNewTitle('bye bye')}}> | ||
{`${newTitle} ${person}` } | ||
</h1> | ||
<input type='text' value={newTitle} /> | ||
</> | ||
) | ||
} | ||
|
||
export default Header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, {memo, useMemo, useCallback, useEffect} from 'react' | ||
|
||
interface ListProps { | ||
elements: string[] | ||
} | ||
|
||
const ListElement = ({ elements }: ListProps): JSX.Element => { | ||
const calculus = useMemo(() => 1 + 2, []) | ||
const handleClick = useCallback((event: any) => { | ||
console.log(event.currentTarget.textContent) | ||
}, []) | ||
return ( | ||
<ul> | ||
{ elements.map((element, index) => { | ||
return ( | ||
<li key={`${element}-${index}`} onClick={handleClick}> | ||
{element} | ||
</li> | ||
)}) | ||
} | ||
</ul> | ||
) | ||
} | ||
|
||
export default memo(ListElement); | ||
|