github nytimes/react-tracking v8.0.0
v8.0.0 - forwardRef support

latest releases: v9.3.2, v9.3.1, v9.3.0...
4 years ago

Added forwardRef support in #153 thanks to @ParadeTo 🎉 . If you'd like to access the internal ref of a tracked component, just add the forwardRef option as part of the second param options object:

@track({}, { forwardRef: true })

Technically the API surface has not changed, we just added a new forwardRef: bool option. But React docs recommend bumping semver major when introducing such a change.

Example:

    const focusFn = () => {};

    @track({}, { forwardRef: true })
    class Child extends React.Component {
      focus = focusFn;

      render() {
        return 'child';
      }
    }

    class Parent extends React.Component {
      componentDidMount() {
        this.child.focus();
      }

      render() {
        return (
          <Child
            ref={el => {
              this.child = el;
            }}
          />
        );
      }
    }

Don't miss a new react-tracking release

NewReleases is sending notifications on new releases.