- bugless.ir [at] yahoo [dot] com
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 { createGlobalStyle } from 'styled-components'; | |
const GlobalStyles = createGlobalStyle` | |
body { | |
overflow-y: hidden; | |
} | |
`; | |
const PageWithoutScrollbar = () => { | |
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
// (1) ----------> Query Object for the useQuery(); | |
import { fetchListFunction } from './services'; | |
export const FetchListObj = (key, config) => ({ | |
queryKey: ['FetchList', key], | |
queryFn: () => fetchListFunction, | |
placeholderData: { | |
list: [] | |
}, |
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
// 1) Using Boolean flag: | |
const [value, setValue] = useState(''); | |
useEffect(() => { | |
let isMounted = true; | |
fetchValue().then(() => { | |
if (isMounted) { | |
setValue('done!'); // no more error | |
} | |
}); |
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 { render } from 'react-dom'; | |
import { QueryClientProvider, QueryClient, useQuery } from 'react-query'; | |
const URL = 'https://randomuser.me/api/?results=5&inc=name'; | |
const One = () => { | |
const { error, data, isLoading, refetch } = useQuery('test', () => | |
fetch(URL).then(response => response.json()) | |
); |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<style> | |
img{ | |
width: 150px; | |
height: auto; |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<style> | |
img{ | |
width: 150px; | |
height: auto; |
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 { render } from 'react-dom'; | |
import axios from 'axios'; | |
class App extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
selectedFile: null, | |
percent: 0 |
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 { render } from 'react-dom'; | |
class App extends React.Component { | |
onChangeFile = (e) => { | |
this.setState({ | |
selectedFile: e.target.files[0] | |
}); | |
} |
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 ReactDOM from 'react-dom'; | |
import { BrowserRouter, Switch, Route, Link, Redirect } from 'react-router-dom'; | |
function Auth() { | |
return false; | |
} | |
const Admin = () => ( | |
<h1>This is Admin page</h1> |
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 ReactDOM from 'react-dom'; | |
import { BrowserRouter, Switch, Route, Link } from 'react-router-dom'; | |
const NotFound = () => ( | |
<h1>404 - Page NotFound !</h1> | |
) | |
const Home = () => ( | |
<h1>Home</h1> |
NewerOlder