Commit Graph

11 Commits

Author SHA1 Message Date
Sebastian Markbage 8f1657bba6 Renamed Descriptor -> Element
We've decided on a new naming convention for ReactDescriptor. It's now
called ReactElement, which is a subset of the ReactNode union type.
2014-10-07 13:41:51 -07:00
Sebastian Markbage 15a0c8920e Don't use React.DOM
I grepped for uses of React.DOM. This is going to be a set of helper functions
to generate ReactElements without JSX.

They're not classes so they cannot be used where a React class is expected.

Since we always use JSX, we should have no internal use for these helpers.
We can use strings instead.
2014-10-07 10:49:18 -07:00
Sebastian Markbage 3aaccd2dc9 Use strings as the type for DOM elements
This makes ReactDOM a simple helper for creating ReactElements with the string tag as the type. The actual class is internal and created by instantiateReactComponent. Configurable using injection.

There's not a separate class for each tag. There's just a generic ReactDOMComponent which could take any tag name.

Invididual tags can be wrapped. When wrapping happens you can return the same tag again. If the wrapper returns the same string, then we fall back to the generic component. This avoids recursion in a single level wrapper.
2014-10-02 23:05:11 -07:00
Ben Alpert d5a4d29532 Fix some linty things 2014-04-28 23:30:05 -03:00
Juraj Dudak 385eb1cef1 Fixed a bug in expectRenderedChildAt
React components have _mountIndex, that looks like it is their order in DOM.
If you swap 2 elements in DOM, their order in children array isn't changed, but their _mountIndex is
2014-04-18 12:57:24 -07:00
Sebastian Markbage c40e06f728 First phase to true descriptors
This moves all convenience constructors to use frozen ReactDescriptors.
2014-03-28 12:32:53 -07:00
Paul O’Shannessy 8a47813baa Update copyrights for 2014.
grep -rl 'Copyright 2013 Facebook' static_upstream | xargs perl -pi -w -e s/Copyright 2013 Facebook/Copyright 2013-2014 Facebook/g;'

Not going to check in a script to do this since it will just change every year.
Closes #1006
2014-02-18 17:06:43 -08:00
Marshall Roch b91396be8e Contexts
Summary:
adds `this.context` which you can think of as implicit props, which are passed automatically down the //ownership// hierarchy.

Contexts should be used sparingly, since they essentially allow components to communicate with descendants (in the ownership sense, not parenthood sense), which is not usually a good idea. You probably would only use contexts in places where you'd normally use a global, but contexts allow you to override them for certain view subtrees which you can't do with globals.

The context starts out `null`:

  var RootComponent = React.createClass({
    render: function() {
      // this.context === null
    }
  });

You should **never** mutate the context directly, just like props and state.

You can change the context of your children (the ones you own, not `this.props.children` or via other props) using the new `withContext` method on `React`:

  var RootComponent = React.createClass({
    render: function() {
      // this.context === null
      var children = React.withContext({foo: 'a', bar: 'b'}, () => (
        // In ChildComponent#render, this.context === {foo: 'a', bar: 'b'}
        <ChildComponent />
      ));
      // this.context === null
    }
  });

Contexts are merged, so a component can override its owner's context **for its children**:

  var ChildComponent = React.createClass({
    render: function() {
      // this.context === {foo: 'a', bar: 'b'} (for the caller above)
      var children = React.withContext({foo: 'c'},() => (
        // In GrandchildComponent#render,
        // this.context === {foo: 'c', bar: 'b'}
        <GrandchildComponent />
      ));
      // this.context === {foo: 'a', bar: 'b'}
    }
  });
2013-11-18 10:56:24 -08:00
CommitSyncScript 36a724feca Add reactComponentExpect#toBeComponentOfType
This adds a `toBeComponentOfType` method to `reactComponentExpect`. Now that we are injecting composite native components, `toBeDOMComponentWithTag` will not suffice and should be deprecated.
2013-06-21 16:02:55 -07:00
CommitSyncScript 0614d30654 Move test utils internally, update for consistency 2013-06-06 14:29:44 -07:00
Paul O’Shannessy 75897c2dcd Initial public release 2013-05-29 12:54:02 -07:00