Skip to content

Commit

Permalink
Merge pull request #35 from reusablejs/typescript
Browse files Browse the repository at this point in the history
Typescript
  • Loading branch information
adamkleingit committed Jun 9, 2019
2 parents a1b1eb8 + fa9e64d commit c6fbfcc
Show file tree
Hide file tree
Showing 17 changed files with 777 additions and 553 deletions.
9 changes: 9 additions & 0 deletions README.md
Expand Up @@ -2,6 +2,9 @@ Go here:
[https://reusablejs.github.io/reusable](https://reusablejs.github.io/reusable)

# tl;dr
Reusable is a library for sharing state and side-effects between components using hooks.
Just wrap your custom hooks with `reusable` and you're good to go.

```javascript
const useSomething = reusable(() => {
//custom hook
Expand All @@ -21,3 +24,9 @@ const App = () => (
</ReusableProvider>
)
```

# What about hooks+Context
Using plain context has some drawbacks, that led us to write this library:
- When managing global state using Context in a large app, you will probably have many small, single-purpose providers. Soon enough you'll find a Provider wrapper hell.
- When you order the providers vertically, you can’t dynamically choose to depend on each other without changing the order, which might break things.
- Context doesn't support selectors, render bailout, or debouncing
2 changes: 1 addition & 1 deletion __tests__/__snapshots__/reusable.test.js.snap
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`reusable should fail without a provider 1`] = `"Error: Are you trying to use Reusable without a ReusableProvider?"`;
exports[`reusable should fail without a provider 1`] = `"Error: Unit doesn't exist"`;
14 changes: 2 additions & 12 deletions docs/basic-usage.md
Expand Up @@ -106,8 +106,8 @@ const Comp = () => {
</a>
## Should I use this in production?
Follow your heart
Reusable is in beta stage.
Follow your heart.
## Feedback & Discussions:
Expand All @@ -118,13 +118,3 @@ Follow your heart
Please do!
Please open an issue for discussion before submitting a PR
What's missing:
- Tests
- TypeScript support
- SSR support
- Better error messages
- More Examples
- lazy-loaded modules example
- API requests
- Keyed states
- 3rd party
7 changes: 7 additions & 0 deletions jest.config.js
@@ -0,0 +1,7 @@
module.exports = {
preset: 'ts-jest',
"transform": {
"^.+\\.jsx?$": "babel-jest", // Adding this line solved the issue
"^.+\\.tsx?$": "ts-jest"
}
};

0 comments on commit c6fbfcc

Please sign in to comment.