-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(store): throw error when hooks used below react 16.8
- Loading branch information
1 parent
e2b1034
commit 152ec88
Showing
10 changed files
with
132 additions
and
49 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,3 @@ | ||
module.exports = process.env.NOHOOK | ||
? require('no-hook-react-testing-library') | ||
: require('@testing-library/react/pure'); |
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,3 @@ | ||
module.exports = process.env.NOHOOK | ||
? require('no-hook-react-dom') | ||
: require('react-dom'); |
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// this is here to avoid duplicate react entries in the examples | ||
// (one from the example's node_modules and one from the root's node_modules) | ||
module.exports = require('react'); | ||
|
||
module.exports = process.env.NOHOOK | ||
? require('no-hook-react') | ||
: require('react'); |
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,17 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react/pure'; | ||
// eslint-disable-next-line import/no-unresolved | ||
import { view, store } from 'react-easy-state'; | ||
|
||
describe('Using an old react version', () => { | ||
test('Using local state in a function component with a version of react that has no hooks should throw an error', () => { | ||
const MyComp = view(() => { | ||
const person = store({ name: 'Bob' }); | ||
return <div>{person.name}</div>; | ||
}); | ||
|
||
expect(() => render(<MyComp />)).toThrow( | ||
'You cannot use state inside a function component with a pre-hooks version of React. Please update your React version to at least v16.8.0 to use this feature.', | ||
); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
{ | ||
"setupFilesAfterEnv": ["./scripts/testSetup.js"], | ||
"testRegex": "\\.test\\.no-hook\\.jsx?$", | ||
"collectCoverage": true, | ||
"coverageReporters": ["lcovonly", "text"], | ||
"collectCoverageFrom": ["src/**/*.{js,jsx}"], | ||
"coverageDirectory": "coverage" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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