Skip to content

Commit 63c49e2

Browse files
author
tomas.jilek
committed
global inject
1 parent 518d742 commit 63c49e2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ Displayed information can be changed using the configuration object, e.g.:
2424
export default debug({name: 'Test'})(MyComponent);
2525
```
2626

27+
### Alternative import
28+
In order to not importing component all the time, you can import `@morosystems/react-debug/lib/patch` just once, in your main file,
29+
then use `debug()` directly from global namespace. You can also safely forget about removing this import for production,
30+
since it will inject `debug()` only when NODE_ENV is `development`
31+
32+
```
33+
import "@morosystems/react-debug/lib/patch";
34+
...
35+
export default debug()(MyComponent);
36+
```
37+
2738
### Component name
2839
You can specify name that is logged using the `name` property. You can specify:
2940
1. String.

src/patch.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import debug from "./debug";
2+
3+
if(process.env.NODE_ENV === "development"){
4+
global.debug = debug;
5+
}

0 commit comments

Comments
 (0)