Skip to content
This repository was archived by the owner on Dec 24, 2020. It is now read-only.

Commit fcb89e2

Browse files
committed
initial commit
1 parent d5bd225 commit fcb89e2

File tree

17 files changed

+170
-486
lines changed

17 files changed

+170
-486
lines changed

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"semi": false,
3+
"singleQuote": false,
4+
"tabWidth": 2,
5+
"trailingComma": "es5"
6+
}

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
# @codefund/react-codefund-hook
1+
# @codefund/react-api-hook
22

33
> CodeFund.io API hook for React.js
44
5-
[![NPM](https://img.shields.io/npm/v/@codefund/react-codefund-hook.svg)](https://www.npmjs.com/package/@codefund/react-codefund-hook) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
5+
[![NPM](https://img.shields.io/npm/v/@codefund/react-api-hook.svg)](https://www.npmjs.com/package/@codefund/react-api-hook) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
66

77
## Install
88

99
```bash
10-
npm install --save @codefund/react-codefund-hook
10+
npm install --save @codefund/react-api-hook
1111
```
1212

1313
## Usage
1414

15+
TODO
16+
<!--
1517
```tsx
1618
import * as React from 'react'
1719
18-
import { useMyHook } from '@codefund/react-codefund-hook'
20+
import { useMyHook } from '@codefund/react-api-hook'
1921
2022
const Example = () => {
2123
const example = useMyHook()
@@ -25,12 +27,8 @@ const Example = () => {
2527
</div>
2628
)
2729
}
28-
```
30+
``` -->
2931

3032
## License
3133

3234
MIT © [andrewmcodes](https://github.com/andrewmcodes)
33-
34-
---
35-
36-
This hook is created using [create-react-hook](https://github.com/hermanya/create-react-hook).

example/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"name": "@codefund/react-codefund-hook-example",
3-
"homepage": "https://andrewmcodes.github.io/@codefund/react-codefund-hook",
2+
"name": "@codefund/react-api-hook-example",
3+
"homepage": "https://andrewmcodes.github.io/@codefund/react-api-hook",
44
"version": "0.0.0",
55
"license": "MIT",
66
"private": true,
77
"dependencies": {
88
"react": "link:../node_modules/react",
99
"react-dom": "^16.9.0",
1010
"react-scripts": "^3.0.1",
11-
"@codefund/react-codefund-hook": "link:.."
11+
"@codefund/react-api-hook": "link:.."
1212
},
1313
"scripts": {
1414
"start": "react-scripts start",

example/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
99

10-
<title>@codefund/react-codefund-hook</title>
10+
<title>@codefund/react-api-hook</title>
1111
</head>
1212

1313
<body>

example/public/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"short_name": "@codefund/react-codefund-hook",
3-
"name": "@codefund/react-codefund-hook",
2+
"short_name": "@codefund/react-api-hook",
3+
"name": "@codefund/react-api-hook",
44
"start_url": "./index.html",
55
"display": "standalone",
66
"theme_color": "#000000",

example/src/Ad.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from 'react'
2+
import { useCodeFundAd } from '@codefund/react-api-hook'
3+
4+
class Ad extends React.Component {
5+
constructor(props) {
6+
super(props);
7+
this.state = {
8+
ad: '',
9+
loading: false,
10+
error: ''
11+
}
12+
}
13+
14+
componentDidMount () {
15+
const { ad, loading, error } = useCodeFundAd('669')
16+
this.setState({
17+
ad: ad,
18+
loading: loading,
19+
error: error
20+
})
21+
}
22+
23+
adMarkup () {
24+
return { __html: this.state.ad }
25+
}
26+
27+
render () {
28+
return <div dangerouslySetInnerHTML={this.adMarkup()} />
29+
}
30+
}
31+
32+
export default Ad

example/src/App.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import React from 'react'
2-
3-
import { useMyHook } from '@codefund/react-codefund-hook'
2+
import { useCodeFundAd } from '@codefund/react-api-hook'
43

54
const App = () => {
6-
const example = useMyHook()
7-
return (
8-
<div>
9-
{example}
10-
</div>
11-
)
5+
const { ad, loading, error } = useCodeFundAd('0')
6+
return <Ad adMarkup={ad} loadingState={loading} errorMessage={error} />
127
}
8+
9+
const Ad = ({ adMarkup, loadingState, errorMessage }) => <div dangerouslySetInnerHTML={adMarkup} />
10+
1311
export default App

0 commit comments

Comments
 (0)