File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,51 @@ This command will run a `webpack-dev-server` and serve your bundle.
3939
4040Navigate to the [ example directory] ( https://github.com/mesaugat/swift-react/tree/master/example ) to see ` swift-react ` in action.
4141
42+ ## Usage with package.json
43+
44+ Add ` swift-react ` as a dev dependency.
45+
46+ ``` bash
47+ $ yarn add swift-react --dev
48+ ```
49+
50+ ``` json
51+ // package.json
52+
53+ {
54+ "name" : " swift-react-example" ,
55+ "scripts" : {
56+ "swift-react" : " swift-react"
57+ },
58+ "devDependencies" : {
59+ "swift-react" : " *"
60+ }
61+ }
62+ ```
63+
64+ Next, create an ` index.js ` file right next to your ` package.json ` file.
65+
66+ ``` js
67+ // index.js
68+
69+ function App () {
70+ return (
71+ < h1> Hello swift- react< / h1>
72+ );
73+ }
74+
75+ // Caution: You don't need to import React or ReactDOM for swift-react to work.
76+ ReactDOM .render (< App / > , document .getElementById (' root' ));
77+ ```
78+
79+ Finally, run this command from the exact place where you created the ` package.json ` and ` index.js ` file.
80+
81+ ``` bash
82+ $ yarn swift-react
83+ ```
84+
85+ * The advantage of this method as compared to the first one is that you don't have to download dependencies of ` swift-react ` again and again.*
86+
4287## Motivation
4388
4489Sometimes testing a small React quirkiness is too cumbersome.
You can’t perform that action at this time.
0 commit comments