This file contains hidden or 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
| import React from 'react'; | |
| function UVHeader(props: any) { | |
| return ( | |
| <div className="uv-header-container"> | |
| <span>{props.data.title}</span> | |
| </div> | |
| ); | |
| } |
This file contains hidden or 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
| import React, { useState } from 'react'; | |
| function Example() { | |
| const [count, setCount] = useState(0); | |
| // count is state variable | |
| // setCount is method to update the count. | |
| // 0 is the default value of count | |
| return ( | |
| <button onClick={() => setCount(count + 1)}> Click me </button> |
This file contains hidden or 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
| import React, { useState, useEffect } from 'react'; | |
| function Example() { | |
| const [count, setCount] = useState(0); | |
| useEffect(() => { | |
| document.title = `You clicked ${count} times`; | |
| }, [count]); // Only re-run the effect if count changes | |
This file contains hidden or 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
| import React, { memo } from 'react'; | |
| function UVNumber(props: any) { | |
| return ( | |
| <div> Memo by Yuvraj Patil</div> | |
| ) | |
| } | |
| export default memo(UVNumber); |
This file contains hidden or 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
| import axios from 'axios'; | |
| const getDashboardData = ()=> { | |
| return axios.get('https://demo1926272.mockable.io/getInvestments'); | |
| } | |
| const UVDashboardApi = { | |
| getDashboardData: getDashboardData | |
| }; |
This file contains hidden or 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
| import React from 'react'; | |
| import UVNumber from '../../components/uv_number/uv_number'; | |
| import { useSelector } from 'react-redux'; | |
| import { UVRootState } from '../../root.reducer'; | |
| function UVDashboard() { | |
| let uvNumberData = useSelector((state: UVRootState) => { | |
| return state.dashboard.numbers; |
This file contains hidden or 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
| import React from 'react'; | |
| function SuccessButton (props: any) { | |
| return ( | |
| <div style={{color: "green"}}>SuccessButton ----------------- {props.data}</div> | |
| ); | |
| } | |
| function WarningButton (props: any) { | |
| return ( |
This file contains hidden or 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
| import React from 'react'; | |
| const UserContext = React.createContext('Yuvraj'); | |
| const UserProvider = UserContext.Provider; | |
| const UserConsumer = UserContext.Consumer; | |
| function UVHeader() { | |
| return ( | |
| <UserConsumer> |
This file contains hidden or 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
| const routes = [ | |
| { | |
| path: "/sandwiches", | |
| component: Sandwiches | |
| }, | |
| { | |
| path: "/tacos", | |
| component: Tacos, | |
| routes: [ | |
| { |
This file contains hidden or 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
| import React, { useMemo } from 'react'; | |
| function App() { | |
| const arr = [1, 2, 33, 4]; | |
| // Memorize output as long as dependency array elements are not changed. | |
| const memiozedValue = useMemo(() => getLargestValue(), [arr]); | |
| function getLargestValue() { | |
| return Math.max(...arr); |