Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(exmaple): add react-class-to-sfc
- Loading branch information
Showing
5 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
plugins: [ | ||
{ | ||
test: /.*.js$/, | ||
plugin: ['transform-react-pure-class-to-function'], | ||
}, | ||
], | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains 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