Commit Graph

10688 Commits

Author SHA1 Message Date
Dan Abramov
487f4bf2ee Update versions for 16.8.6 2019-03-27 23:55:48 -07:00
Dan Abramov
297165f1e1 Port tests to old API 2019-03-27 15:40:51 -07:00
Dan Abramov
cd5b8950a0 Changelog 2019-03-27 08:54:25 -07:00
Renan Valentin
f00be84b81 fix(react-dom): access iframe contentWindow instead of contentDocument (#15099)
MDN has a list of methods for obtaining the window reference of an
iframe:

https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#Syntax

fix(react-dom): check if iframe belongs to the same origin

Accessing the contentDocument of a HTMLIframeElement can cause the browser
to throw, e.g. if it has a cross-origin src attribute.
Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g:

```javascript
try {
 $0.contentDocument.defaultView
} catch (err) {
  console.log('err', err)
}

> Blocked a frame with origin X from accessing a frame with origin Y. Protocols, domains, and ports must match.
> err – TypeError: null is not an object (evaluating '$0.contentDocument.defaultView')
```

A safety way is to access one of the cross origin properties: Window or Location
Which might result in "SecurityError" DOM Exception and it is compatible to Safari.

```javascript
try {
 $0.contentWindow.location.href
} catch (err) {
 console.log('err', err)
}

> err – SecurityError: Blocked a frame with origin "http://localhost:3001" from accessing a cross-origin frame. Protocols, domains, and ports must match.
```

https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl
2019-03-27 08:45:32 -07:00
Dan Abramov
e0c2c56dfd Improve warning for invalid class contextType (#15142)
* Improve warning for invalid class contextType

* Don't warn for null

* Grammar
2019-03-27 08:45:20 -07:00
Brandon Dail
aa8736a3a9 Warn for Context.Consumer with contextType (#14831) 2019-03-27 08:45:13 -07:00
Andrew Clark
d9fa20d52f Eager bailout optimization should always compare to latest reducer (#15124)
* Eager bailout optimization should always compare to latest reducer

* queue.eagerReducer -> queue.lastRenderedReducer

This name is a bit more descriptive.

* Add test case that uses preceding render phase update
2019-03-27 08:45:04 -07:00
Dan Abramov
84cc8a31fa Release 16.8.5 2019-03-22 16:42:00 +00:00
Dan Abramov
f9e41e3a51 Changelog 2019-03-22 14:49:12 +00:00
Jared Palmer
fb572afc14 Add more info to invalid hook call error message (#15139)
* Add more info to invalid hook call error message

* Update other renderers + change call to action

* Update related tests for new hooks error message

* Fix lint errors
2019-03-22 14:47:58 +00:00
Dan Abramov
a0a2e846ce
Update CHANGELOG.md 2019-03-22 14:37:19 +00:00
Dan Abramov
1fc13e4b35 Add 16.8.5 changelog 2019-03-22 14:34:33 +00:00
Dan Abramov
b5cb9d345c Link to useLayoutEffect gist in a warning (#15158) 2019-03-22 14:14:46 +00:00
Dan Abramov
342fa78ed4 [Shallow] Implement setState for Hooks and remount on type change (#15120)
* Throw away old shallow renderer state on type change

This worked in function components but was broken for classes. It incorrectly retained the old instance even if the type was different.

* Remove _previousComponentIdentity

We only needed this because we didn't correctly reset based on type. Now we do so this can go away.

* Use _reset when unmounting

* Use arbitrary componentIdentity

There was no particular reason it was set to element.type. We just wanted to check if something is a render phase update.

* Support Hook state updates in shallow renderer
2019-03-22 14:13:28 +00:00
Brandon Dail
62f5d4a057 Support React.memo in ReactShallowRenderer (#14816)
* Support React.memo in ReactShallowRenderer

ReactShallowRenderer uses element.type frequently, but with React.memo
elements the actual type is element.type.type. This updates
ReactShallowRenderer so it uses the correct element type for Memo
components and also validates the inner props for the wrapped
components.

* Allow Rect.memo to prevent re-renders

* Support memo(forwardRef())

* Dont call memo comparison function on initial render

* Fix test

* Small tweaks
2019-03-22 14:13:15 +00:00
Dan Abramov
6b86a6e039 Use same example code for async effect warning (#15118) 2019-03-22 14:13:05 +00:00
Sebastian Silbermann
8f7335875c Fix shallow renderer not allowing hooks in forwardRef render functions (#15100)
* test: Add test for shallow + forwardRef + hook

* fix(react-test-renderer): shallow forwardRef hooks
2019-03-22 14:12:24 +00:00
Mateusz
d822d4bbe7 Don't set the first option as selected in select tag with size attribute (#14242)
* Set 'size' attribute to select tag if it occurs before appending options

* Add comment about why size is assigned on select create. Tests

I added some more clarification for why size must be set on select
element creation:

- In the source code
- In the DOM test fixture
- In a unit test

* Use let, not const in select tag stub assignment
2019-03-22 14:12:11 +00:00
Dan Abramov
13a3788c54 Improve async useEffect warning (#15104) 2019-03-22 14:11:22 +00:00
Brian Vaughn
d8a73b5eb6 16.8.4 and changelog 2019-03-05 15:16:01 -08:00
Brian Vaughn
741aa17a33 Turning off eslint-plugin-react-hooks for the upcoming patch release 2019-03-05 14:35:53 -08:00
Brian Vaughn
95c2b49543 Cherry picked 4186952 from master, but with manually resolved conflicts.
Original commit: Fixed incompatibility between react-debug-tools and useContext() (#14940)
* Refactor hook ordering check to use DEV-only data structure. This enables us to warn about more cases (e.g. useContext, useDebugValue) withou the need to add any overhead to production bundles.
2019-03-05 14:29:04 -08:00
Dan Abramov
55cf14f98e Release 16.8.3 2019-03-05 14:09:10 -08:00
Dan Abramov
29b7b775f2 Fix UMD builds by re-exporting the scheduler priorities (#14914) 2019-02-21 17:21:38 +00:00
overlookmotel
b668168d4d Fix react-dom/server context leaks when render stream destroyed early (#14706)
* Fix react-dom/server context memory retention

* Test for pollution of later renders

* Inline loop

* More tests
2019-02-20 11:25:02 -08:00
Dan Abramov
619cdfc624 Don't discard render phase state updates with the eager reducer optimization (#14852)
* Add test cases for setState(fn) + render phase updates

* Update eager state and reducer for render phase updates

* Fix a newly firing warning
2019-02-20 11:24:49 -08:00
Dan Abramov
3e55560438 Release 16.8.2 2019-02-14 19:13:15 +00:00
Dan Abramov
dfabb77a97
Include another change in 16.8.2 2019-02-14 17:21:27 +00:00
Sunil Pai
c555c008b6 Include component stack in 'act(...)' warning (#14855)
* add a component stack trace to the act() warning

* pass tests

* nit
2019-02-14 17:20:49 +00:00
Dan Abramov
ff188d666b
Add React 16.8.2 changelog (#14851) 2019-02-14 14:51:01 +00:00
Deniz Susman
c4d8ef6430 Fix typo in code comment (#14836) 2019-02-13 20:49:37 -08:00
Sebastian Markbåge
08e9554357
Statically enable suspense/partial hydration flag in www (#14842)
It doesn't hurt to have this always on since it is only when we use
Suspense that it matters. This saves some code/checks.
2019-02-13 10:55:13 -08:00
Dan Abramov
0e4135e8c2
Revert "[ShallowRenderer] Queue/rerender on dispatched action after render component with hooks (#14802)" (#14839)
This reverts commit 6d4038f0a6.
2019-02-13 16:52:14 +00:00
Rodrigo Ribeiro
6d4038f0a6 [ShallowRenderer] Queue/rerender on dispatched action after render component with hooks (#14802)
* [shallow-renderer] Rerender on dispatched action out of render
2019-02-13 15:59:02 +00:00
Brandon Dail
fa6205d522
Special case crossOrigin for SVG image elements (#14832) 2019-02-12 20:13:17 -08:00
Dan Abramov
c6bee765ba
Remove false positive warning and add TODOs about current being non-null (#14821)
* Failing test for false positive warning

* Add tests for forwardRef too

* Remove the warning and add TODOs
2019-02-13 00:00:10 +00:00
Dan Abramov
3ae94e1885
Fix ignored sync work in passive effects (#14799)
* Fix ignored sync work in passive effects

* Fix batching
2019-02-12 20:18:35 +00:00
Sebastian Markbåge
f3a14951ab
Partial Hydration (#14717)
* Basic partial hydration test

* Render comments around Suspense components

We need this to be able to identify how far to skip ahead if we're not
going to hydrate this subtree yet.

* Add DehydratedSuspenseComponent type of work

Will be used for Suspense boundaries that are left with their server
rendered content intact.

* Add comment node as hydratable instance type as placeholder for suspense

* Skip past nodes within the Suspense boundary

This lets us continue hydrating sibling nodes.

* A dehydrated suspense boundary comment should be considered a sibling

* Retry hydrating at offscreen pri or after ping if suspended

* Enter hydration state when retrying dehydrated suspense boundary

* Delete all children within a dehydrated suspense boundary when it's deleted

* Delete server rendered content when props change before hydration completes

* Make test internal

* Wrap in act

* Change SSR Fixture to use Partial Hydration

This requires the enableSuspenseServerRenderer flag to be manually enabled
for the build to work.

* Changes to any parent Context forces clearing dehydrated content

We mark dehydrated boundaries as having child work, since they might have
components that read from the changed context.

We check this in beginWork and if it does we treat it as if the input
has changed (same as if props changes).

* Wrap in feature flag

* Treat Suspense boundaries without fallbacks as if not-boundaries

These don't come into play for purposes of hydration.

* Fix clearing of nested suspense boundaries

* ping -> retry

Co-Authored-By: sebmarkbage <sebastian@calyptus.eu>

* Typo

Co-Authored-By: sebmarkbage <sebastian@calyptus.eu>

* Use didReceiveUpdate instead of manually comparing props

* Leave comment for why it's ok to ignore the timeout
2019-02-11 21:25:44 -08:00
Dan Abramov
f24a0da6e0
Fix useImperativeHandle to have no deps by default (#14801)
* Fix useImperativeHandle to have no deps by default

* Save a byte?

* Nit: null
2019-02-11 18:42:28 +00:00
Dan Abramov
1fecba9230
Fix crash unmounting an empty Portal (#14820)
* Adds failing test for https://github.com/facebook/react/issues/14811

* Fix removeChild() crash when removing an empty Portal
2019-02-11 18:37:53 +00:00
Alexey Raspopov
e15542ee0f use functional component as a first example in readme (#14819) 2019-02-11 14:41:37 +00:00
zhuoli99
c11015ff4f fix spelling mistakes (#14805) 2019-02-09 16:43:49 -08:00
Deniz Susman
3e295edd52 Typo fix in comment (#14787) 2019-02-09 16:42:55 -08:00
Sebastian Markbåge
1d48b4a684
Fix hydration with createRoot warning (#14808)
It's suggesting an API that doesn't exist. Fixed it to reference the actual
API.
2019-02-09 17:12:11 +00:00
Brian Vaughn
aa9423701e Tweaked publish canary message to show newly published version 2019-02-06 18:24:51 +00:00
Brian Vaughn
45fc46bfa0 16.8.1 packages 2019-02-06 18:21:33 +00:00
Dan Abramov
b7cc6b2e6f
Add 16.8.1 changelog 2019-02-06 18:19:35 +00:00
Brian Vaughn
f2e2637c8e
Backwards compat fix for ReactCurrentDispatcher on older react versions (#14770)
* Add current owner ref fallback for newer renderers with older react versions
* Replaced current owner forward with current:null
2019-02-06 17:02:14 +00:00
Sunil Pai
1107b9673c
[TestUtils.act] warn when using TestUtils.act in node (#14768)
* warn when using TestUtils.act in node

* s/warns/throws

* s/throw/warn

* consistent ellipses
2019-02-06 16:25:26 +00:00
Brian Vaughn
0975ea3278 eslint-plugin-react-hooks v1.0.0 2019-02-06 10:14:57 +00:00