1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  *
    
  7.  * @emails react-core
    
  8.  */
    
  9. 
    
  10. 'use strict';
    
  11. 
    
  12. let React = require('react');
    
  13. const ReactTestUtils = require('react-dom/test-utils');
    
  14. 
    
  15. class TextWithStringRef extends React.Component {
    
  16.   render() {
    
  17.     jest.resetModules();
    
  18.     React = require('react');
    
  19.     return <span ref="foo">Hello world!</span>;
    
  20.   }
    
  21. }
    
  22. 
    
  23. describe('when different React version is used with string ref', () => {
    
  24.   it('throws the "Refs must have owner" warning', () => {
    
  25.     expect(() => {
    
  26.       ReactTestUtils.renderIntoDocument(<TextWithStringRef />);
    
  27.     }).toThrow(
    
  28.       'Element ref was specified as a string (foo) but no owner was set. This could happen for one of' +
    
  29.         ' the following reasons:\n' +
    
  30.         '1. You may be adding a ref to a function component\n' +
    
  31.         "2. You may be adding a ref to a component that was not created inside a component's render method\n" +
    
  32.         '3. You have multiple copies of React loaded\n' +
    
  33.         'See https://reactjs.org/link/refs-must-have-owner for more information.',
    
  34.     );
    
  35.   });
    
  36. });