Skip to content

Commit c5db872

Browse files
adding codecov and other badges
1 parent 9a84b18 commit c5db872

File tree

3 files changed

+39
-37
lines changed

3 files changed

+39
-37
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ example/node_modules
88

99
# testing
1010
/coverage
11+
/sandbox
1112

1213
# production
1314
/build

README.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# string-to-react-component
1+
[![Test coverage](https://codecov.io/gh/dev-javascript/string-to-react-component/graph/badge.svg?token=GT1LU074L2)](https://codecov.io/gh/dev-javascript/string-to-react-component) [![NPM version](http://img.shields.io/npm/v/string-to-react-component.svg?style=flat-square)](http://npmjs.org/package/string-to-react-component) [![node](https://img.shields.io/badge/node.js-%3E=_8.0-green.svg?style=flat-square)](http://nodejs.org/download/) [![React](https://img.shields.io/badge/React-%3E=_16.8.0-green.svg?style=flat-square)](https://react.dev/) [![License](http://img.shields.io/npm/l/string-to-react-component.svg?style=flat-square)](LICENSE) [![npm download](https://img.shields.io/npm/dm/string-to-react-component.svg?style=flat-square)](https://npmjs.org/package/string-to-react-component) [![Build Status](https://travis-ci.org/ly-components/string-to-react-component.png)](https://travis-ci.org/ly-components/string-to-react-component)
22

3-
Create React component from string
3+
# string-to-react-component
44

5-
> _Support react >= `v16.8.0`_
5+
Create React component from string
66

77
## Table of Contents
88

@@ -116,38 +116,38 @@ function App() {
116116
- not required
117117
- See the full option list [here](https://babeljs.io/docs/en/options)
118118
- examples :
119-
* using source map :
120-
```js
121-
<StringToReactComponent babelOptions={{filename: 'counter.js', sourceMaps: 'inline'}}>
122-
{`(props)=>{
123-
const {useState}=React;
124-
const [counter,setCounter]=useState(0);
125-
const increase=()=>{
126-
setCounter(counter+1);
127-
};
128-
return (<>
129-
<button onClick={increase}>+</button>
130-
<span>{'counter : '+ counter}</span>
131-
</>);
132-
}`}
133-
</StringToReactComponent>
134-
```
135-
* using typescript :
136-
```js
137-
<StringToReactComponent babelOptions={{ filename: 'counter.ts',presets: [["typescript", { allExtensions: true, isTSX: true }]] }}>
138-
{`()=>{
139-
const [counter,setCounter]=React.useState<number>(0);
140-
const increase=()=>{
141-
setCounter(counter+1);
142-
};
143-
return (<>
144-
<button onClick={increase}>+</button>
145-
<span>{'counter : '+ counter}</span>
146-
</>);
147-
}`}
148-
</StringToReactComponent>
149-
```
150-
119+
- using source map :
120+
```js
121+
<StringToReactComponent babelOptions={{filename: 'counter.js', sourceMaps: 'inline'}}>
122+
{`(props)=>{
123+
const {useState}=React;
124+
const [counter,setCounter]=useState(0);
125+
const increase=()=>{
126+
setCounter(counter+1);
127+
};
128+
return (<>
129+
<button onClick={increase}>+</button>
130+
<span>{'counter : '+ counter}</span>
131+
</>);
132+
}`}
133+
</StringToReactComponent>
134+
```
135+
- using typescript :
136+
```js
137+
<StringToReactComponent
138+
babelOptions={{filename: 'counter.ts', presets: [['typescript', {allExtensions: true, isTSX: true}]]}}>
139+
{`()=>{
140+
const [counter,setCounter]=React.useState<number>(0);
141+
const increase=()=>{
142+
setCounter(counter+1);
143+
};
144+
return (<>
145+
<button onClick={increase}>+</button>
146+
<span>{'counter : '+ counter}</span>
147+
</>);
148+
}`}
149+
</StringToReactComponent>
150+
```
151151

152152
## Caveats
153153

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"build:lib:esm-pf": "cross-env INCLUDE_POLYFILLS=true babel src/ --out-dir lib/esm-including-polyfills/ --ignore **/__tests__,**/__mocks__,**/*.test.js,**/*.js.snap",
2626
"clean:lib": "rimraf lib",
2727
"clean:dist": "rimraf dist",
28-
"prepublish": "npm run build",
28+
"prepublishOnly": "npm run build",
2929
"test": "jest",
3030
"lint": "eslint src",
3131
"deploy": "gh-pages -d demo"
@@ -89,7 +89,8 @@
8989
"jest": {
9090
"setupFilesAfterEnv": [
9191
"jest-extended"
92-
]
92+
],
93+
"collectCoverage": true
9394
},
9495
"dependencies": {
9596
"prop-types": "^15.8.1"

0 commit comments

Comments
 (0)