Skip to content

Commit

Permalink
chore(exmaple): add react-class-to-sfc
Browse files Browse the repository at this point in the history
  • Loading branch information
akameco committed Feb 18, 2018
1 parent 3dd8106 commit 24b8a70
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 0 deletions.
19 changes: 19 additions & 0 deletions examples/react-class-to-sfc/package.json
@@ -0,0 +1,19 @@
{
"name": "example-react-class-to-sfc",
"version": "0.0.0",
"private": true,
"description": "sample react class to sfc",
"license": "MIT",
"repository": "https://github.com/akameco/s2s",
"author": "akameco <akameco.t@gmail.com> (akameco.github.io)",
"engines": {
"node": ">=6"
},
"scripts": {
"s2s": "s2s"
},
"devDependencies": {
"babel-plugin-transform-react-pure-class-to-function": "^1.0.1",
"s2s": "^0.18.1"
}
}
29 changes: 29 additions & 0 deletions examples/react-class-to-sfc/readme.md
@@ -0,0 +1,29 @@
## Run

```
yarn s2s
```

## s2s

```js
import * as React from 'react'

class App extends React.Component {
render() {
return <div>Hello SFC :)</div>
}
}

export default App

↓ ↓ ↓

import * as React from 'react'

function App(props) {
return <div>Hello SFC :)</div>
}

export default App
```
8 changes: 8 additions & 0 deletions examples/react-class-to-sfc/s2s.config.js
@@ -0,0 +1,8 @@
module.exports = {
plugins: [
{
test: /.*.js$/,
plugin: ['transform-react-pure-class-to-function'],
},
],
}
12 changes: 12 additions & 0 deletions examples/react-class-to-sfc/src/index.js
@@ -0,0 +1,12 @@
import * as React from 'react'

class App extends React.Component {
onClick = () => {
console.log('remove onClick & save')
}
render() {
return <div>Hello SFC :)</div>
}
}

export default App
10 changes: 10 additions & 0 deletions yarn.lock
Expand Up @@ -694,6 +694,10 @@ babel-helper-hoist-variables@^6.24.1:
babel-runtime "^6.22.0"
babel-types "^6.24.1"

babel-helper-is-react-class@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/babel-helper-is-react-class/-/babel-helper-is-react-class-1.0.0.tgz#ef6f3678b05c76dbdeedadead7af98c2724d8431"

babel-helper-optimise-call-expression@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz#f7a13427ba9f73f8f4fa993c54a97882d1244257"
Expand Down Expand Up @@ -1119,6 +1123,12 @@ babel-plugin-transform-react-jsx@6.24.1, babel-plugin-transform-react-jsx@^6.24.
babel-plugin-syntax-jsx "^6.8.0"
babel-runtime "^6.22.0"

babel-plugin-transform-react-pure-class-to-function@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-pure-class-to-function/-/babel-plugin-transform-react-pure-class-to-function-1.0.1.tgz#32a649c97d653250b419cfd1489331b0290d9ee4"
dependencies:
babel-helper-is-react-class "^1.0.0"

babel-plugin-transform-regenerator@6.26.0, babel-plugin-transform-regenerator@^6.22.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz#e0703696fbde27f0a3efcacf8b4dca2f7b3a8f2f"
Expand Down

0 comments on commit 24b8a70

Please sign in to comment.