Skip to content

Commit 76f3779

Browse files
committed
app-dev main app.js
1 parent 8afcf92 commit 76f3779

3 files changed

Lines changed: 20 additions & 66 deletions

File tree

app-dev/src/App.js

Lines changed: 18 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,23 @@
1-
// import React from 'react'
2-
// // import FakerComponents from './examples/components/Faker'
3-
// // import JsonPlaceHolderComponents from './examples/components/JsonPlaceHolder'
4-
// // import DummyComponents from './examples/components/Dummy'
5-
// // import UIFacesComponents from './examples/components/UIFaces'
6-
// // import { useStarWars } from './development/hooks/StarWars'
7-
// import { useStarWars } from 'react-fakers'
8-
9-
// const App = () => {
10-
// const { success, error, loading } = useStarWars()
11-
// if (error) {
12-
// console.log(error.message)
13-
// }
14-
15-
// return (
16-
// <>
17-
// {!loading && <h4>Loading....</h4>}
18-
// <ul>{loading && success.map((val, id) => <li key={id}>{val.name}</li>)}</ul>
19-
// </>
20-
// )
21-
// }
22-
23-
// export default App
24-
25-
import React, { Component } from 'react'
26-
import { Faker } from 'react-fakers'
27-
28-
class App extends Component {
29-
constructor(props) {
30-
super(props)
31-
this.state = {
32-
loading: false,
33-
data: []
34-
}
1+
import React from 'react'
2+
import { useStarWars } from 'react-fakers'
3+
// import FakerComponents from './examples/components/Faker'
4+
// import JsonPlaceHolderComponents from './examples/components/JsonPlaceHolder'
5+
// import DummyComponents from './examples/components/Dummy'
6+
// import UIFacesComponents from './examples/components/UIFaces'
7+
// import { useStarWars } from './development/hooks/StarWars'
8+
9+
const App = () => {
10+
const { success, error, loading } = useStarWars()
11+
if (error) {
12+
console.log(error.message)
3513
}
3614

37-
onSuccess = (res) => {
38-
this.setState({
39-
loading: true,
40-
data: res
41-
})
42-
}
43-
44-
onError = (error) => {
45-
if (error) {
46-
alert(error.message)
47-
}
48-
}
49-
50-
render() {
51-
return (
52-
<>
53-
<Faker success={this.onSuccess} error={this.onError} />
54-
55-
{!this.state.loading && <h4>Loading....</h4>}
56-
<ul>
57-
{this.state.loading &&
58-
this.state.data.map((val, id) => (
59-
<li key={val.uuid}>
60-
{val.firstname} {val.lastname} - {val.email}
61-
</li>
62-
))}
63-
</ul>
64-
</>
65-
)
66-
}
15+
return (
16+
<>
17+
{!loading && <h4>Loading....</h4>}
18+
<ul>{loading && success.map((val, id) => <li key={id}>{val.name}</li>)}</ul>
19+
</>
20+
)
6721
}
6822

6923
export default App

build/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/index.nomin.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)