Commit Graph
386 Commits
Author SHA1 Message Date
Jim 3afced6a75 Error boundaries. 2015-12-16 12:15:26 -08:00
Sebastian Markbage 0b063f8a09 Reorganize Src Files for Isomorphic React Package
The new folder structure is organized around major packages that are expected to ship separately in some form.

`/isomorphic`

I moved classic/modern and children utils into a directory called "isomorphic" with the main export being ReactIsomorphic. This will eventually become the "react" package.

This includes all the dependencies that you might need to create a component without dependencies on the renderer/reconciler.

The rest moves into decoupled renderers.

`/renderers/dom/client` - This is the main renderer for DOM.

`/renderers/dom/server` - This is the server-side renderer for HTML strings.

`/addons` and `/test` - Same as before for now.

You're not supposed to take on a dependency inside another package.

Shared code is organized into a "shared" directory which is intended to support all the packages in that subdirectory. Meaning that once we swap to CommonJS modules, the only time you should use `..` is to target `../shared/` or `../../shared`.

E.g. `/shared/` is common utils that are used by everything.

`/renderers/shared/` is code that is shared by all renderers, such as the main reconciliation algorithm.

Shared code will likely be copied into each package rather than referenced. This allow us to have separate state and allow inlining and deadcode elimination.
2015-05-15 18:35:22 -07:00
Paul O’Shannessy 1549bae2ab Merge pull request #3834 from chicoxyzzy/remove_jslint
remove jslint comments
2015-05-10 22:52:57 -07:00
Ben Alpert 4ba67670f9 Merge pull request #3841 from spicyj/yolo
Preserve prototype with replaceState
2015-05-08 13:16:43 -07:00
Ben Alpert d7de12fbd8 Preserve prototype with replaceState
Fixes #3418.
2015-05-08 13:11:18 -07:00
chico 553dd90528 remove jslint comments 2015-05-08 03:05:51 +03:00
Yakov Dalinchuk 9b798400fd ReactMultiChildText-test.js fix __html typo 2015-05-07 16:06:11 +03:00
Tomasz Kołodziejski 5ef0b416df IsMounted should always return a boolean.
Fixes #3814. isMounted used to return undefined if internalInstance
was undefined after component was unmounted.
2015-05-05 11:43:09 +02:00
Ben Alpert 36f3a2aaff Batch updates within top-level unmount
Analogous change to #2935.
2015-04-30 15:05:44 -07:00
Jim 9a950e9a19 Added unit test to verify that context treats the component doing a render() as the parent. 2015-04-27 14:56:25 -07:00
Jim 0185c68c91 Merge pull request #3615 from jsfb/enable-new-context
Switch to parent-based context.  Fixes #2112.
2015-04-09 13:21:26 -07:00
Ben Alpert e60a26a682 Kill ReactDoNotBindDeprecated
No one uses this.
2015-04-08 15:15:02 -07:00
Paul O’Shannessy a34cf222ba Merge pull request #3604 from Charca/firefox-tests-fixes
Fixes for several failing tests in Firefox and Safari
2015-04-08 10:34:57 -07:00
Baraa Hamodi c9e3a32bc5 Update ReactCompositeComponentNestedState-test.js 2015-04-08 13:02:43 -04:00
Jim 7d44917531 Switch to parent-based context. Fixes #2112. 2015-04-07 14:49:29 -07:00
Maxi Ferreira 49745e7bff Fixes for several failing tests in Firefox and Safari 2015-04-07 01:37:27 -03:00
Ben Alpert 5a01f5f6a9 Fix ResponderEventPlugin to work in core React again
Test Plan: jest, grunt fasttest
2015-04-02 13:33:47 -07:00
Ben Alpert b32fbef7c5 Add missing semicolon 2015-03-25 18:10:49 -07:00
Paul O’Shannessy 56b180b464 Fix failing test
PR #3494 was based on master before we shifted to using console.error. This
just fixes the new test case.
2015-03-25 12:15:41 -07:00
Jim 13dbda3644 Merge pull request #3494 from letiemble/B_Context_Rerender
Fix the context handling when updating a rendered component.
2015-03-25 11:55:35 -07:00
Ben Alpert 4dde417214 Fix tests after merge
Test Plan: jest
2015-03-24 13:37:39 -07:00
Ben Alpert 1aa4e3c234 Merge pull request #3440 from spicyj/console-error
Use console.error to show stack trace in console
2015-03-24 13:30:01 -07:00
Laurent Etiemble 357345a56d Fix the context handling when updating a rendered component. 2015-03-24 08:29:09 +01:00
cpojer fb23276178 Add warning for getDOMNode calls. 2015-03-17 14:08:04 -07:00
Ben Alpert e791fccf58 Use console.error to show stack trace in console
Better version of #3277.

Test Plan: jest, grunt test
2015-03-17 13:39:04 -07:00
Sebastian Markbage 50cbdbc9ab Don't use owner to determine statefulness
This reverts an early commit that made it so that elements from two
different owner in the same slot wouldn't share state.

That behavior was helpful, and we did hit a case which was solved by this.
However, this pattern is extremely uncommon. I've yet to even find the
original case, let alone any existing cases in our codebase.

Therefore, we're dropping this to simplify elements and enable new
optimizations.
2015-03-16 18:05:15 -07:00
cpojer 413e96d0cd Add some important getDOMNode tests back. 2015-03-10 17:27:19 -07:00
cpojer ae7da3aadd foo.getDOMNode => React.findDOMNode(foo) 2015-03-10 17:17:21 -07:00
Ben Alpert f77de57e41 Merge pull request #2946 from benmoss/nested-render-warning
Add displayName to nested render warnings [#1726]
2015-03-10 15:24:59 -07:00
Ben Alpert 6b7e4dc8e8 Add warning when using non-component element types
This should make debugging easier for people who missed callsites when fixing up their JSX/non-JSX usage.
2015-03-05 15:24:31 -08:00
Paul O’Shannessy a3ee6a9548 Merge pull request #2993 from chenglou/classset-ded
Put deprecation warning for classSet
2015-02-19 18:36:36 -08:00
Cheng Lou 835316bc13 Put deprecation warning for classSet
Also removes the one test that used the module.
2015-02-19 19:31:54 -05:00
Henry Zhu eba5d1365c lint: remove spaces from array brackets 2015-02-19 00:13:36 -05:00
Henry Zhu 07cfd66028 lint: remove spaces from object braces 2015-02-19 00:10:31 -05:00
Sebastian Markbåge cf4bef8bd7 Merge pull request #3171 from sebmarkbage/moarwarnings
Moar Warnings
2015-02-17 15:09:33 -08:00
Sebastian Markbage 2490289c4a Warn if getDOMNode or isMounted is accessed in render
This is an anti-pattern that can be easily avoided by putting the logic
in componentDidMount and componentDidUpdate instead.

It creates a dependency on stale data inside render without enforcing
a two-pass render.
2015-02-17 11:49:20 -08:00
Henry Zhu 74726f0af5 remove space before round brace in function expressions 2015-02-13 23:41:53 -05:00
Henry Zhu e2a57920da lint whitespace , trailing comma 2015-02-13 23:13:47 -05:00
Jim 207b03c56d Dedupe owner-is-important warning. 2015-02-13 18:05:18 -08:00
Sebastian Markbage f5038829d8 Moar warnings with solid prefixes!
This ensures that we have a prefix that can be easily identified in logs
so that we can filter out warnings based on their prefix.

This also turns the remaining two monitorCodeUse callers into warnings.
We'll probably still use monitorCodeUse until we know if we want to
deprecate but most releases should only have warnings.
2015-02-12 13:37:19 -08:00
Jim 4e5543965d Flip console.warn to use warning module so users can intercept all warnings by shimming the warning module.
The two remaining console.warns are:

/Users/jsproch/react/src/test/mock-modules.js:
   19      return mocks.generateFromMetadata(mocks.getMetadata(exports));
   20    } catch (err) {
   21:     console.warn(err);
   22      return exports;
   23    }

/Users/jsproch/react/src/vendor/core/warning.js:
   39        var argIndex = 0;
   40        var message = 'Warning: ' + format.replace(/%s/g, () => args[argIndex++]);
   41:       console.warn(message);
   42        try {
   43          // --- Welcome to debugging React ---
2015-02-10 15:23:24 -08:00
Paul O’Shannessy f6f0bab237 Merge pull request #3103 from zpao/lifecyle-warn-not-throw
Warn when calling setState & other methods at wrong time
2015-02-10 09:58:34 -08:00
Matias Singers b9310a8fa5 Consistently use calls.length instead of callCount for Jasmine spies 2015-02-10 10:11:22 +08:00
Paul O’Shannessy 5967915ec4 Warn when calling setState & other methods at wrong time
Currently we use an invariant to prevent this code pattern. That is really
aggressive for something that doesn't actually put React in a bad state. This
diff replaces invariants with warnings and makes those code paths no-ops.
2015-02-09 17:04:13 -08:00
Sebastian Markbage 56f51156ba Make keyed object fragments an opaque type
This triggers a warning if you try to pass a keyed object as a child.

You now have to wrap it in React.addons.createFragment(object) which
creates a proxy (in dev) which warns if it is accessed. The purpose of
this is to make these into opaque objects so that nobody relies on its
data structure.

After that we can turn it into a different data structure such as a
ReactFragment node or an iterable of flattened ReactElements.
2015-02-09 14:24:56 -08:00
Sebastian Markbage 263800e09b Fix isMounted inside of render
This is apparently used to determine if you can access refs.

Bad pattern, but a pattern nonetheless.
2015-02-04 11:50:04 -08:00
Lee Byron 9174501771 Merge pull request #2991 from leebyron/state-queue
Set state takes a function
2015-02-03 19:52:26 -05:00
Lee Byron 279b956c9b Set state takes a function
This diff enables setState to accept a function in addition to a state partial. If you provide a function, it will be called with the up-to-date `state, props, context` as arguments.

This enables some nicer syntax for complex setState patterns:

If setState is doing an increment and wants to guarantee atomicy, you need a function:

```
this.setState(state => ({ number: state.number + 1 }));
```

This atomicy is particularly important if setState is called multiple times in a single frame of execution as the result of complex user actions. It's a tricky bug to chase down and difficult to determine how to fix when you find it. The current pattern of reaching into _pendingState relies on an implementation detail.

In this example: props.doAction() may result in your ancestor re-rendering and providing you with new props. If setState is called directly with an object literal referencing `this.props`, it will use the *old* version of props, not the new value. Using a function solves for this case:

```
this.props.doAction();
this.setState((state, props) => ({ number: state.number * props.multiplier }));
```
2015-02-03 19:49:17 -05:00
Sebastian Markbage 2702281a13 Always trigger an update when a callback is enqueued.
enqueueCallbackInternal forgot to schedule an update.

We could rely on the implicit contract of enqueueElement to do it. However,
if we're currently outside a transaction, it'll flush synchronously. Before
we enqueue the callback. We could also enqueueCallback before we
enqueueElement, but that causes a fragile relationship between them. E.g.
enqueueElement should not need to schedule an update if it is the same
element.
2015-02-02 20:42:15 -08:00
Ben Moss ba55716a2d Fix warning messages wording and access of displayName 2015-02-02 18:05:31 -05:00