Home / File/ switch-date-test-case.js — react Source File

switch-date-test-case.js — react Source File

Architecture documentation for switch-date-test-case.js, a javascript file in the react codebase. 0 imports, 1 dependents.

File javascript BabelCompiler Optimization 1 dependents 1 classes

Entity Profile

Dependency Diagram

graph LR
  595c8d7b_f848_6c78_07aa_cf8e45db9dd6["switch-date-test-case.js"]
  f91798bc_7834_6a3e_b26a_92e61ba9eb26["index.js"]
  f91798bc_7834_6a3e_b26a_92e61ba9eb26 --> 595c8d7b_f848_6c78_07aa_cf8e45db9dd6
  style 595c8d7b_f848_6c78_07aa_cf8e45db9dd6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

const React = window.React;

const startDate = new Date();
/**
 * This test case was originally provided by @richsoni,
 * https://github.com/facebook/react/issues/8116
 */
class SwitchDateTestCase extends React.Component {
  state = {
    fullDate: false,
    date: startDate,
  };

  render() {
    const attrs = this.inputAttrs();

    return (
      <div>
        <p>
          <b>{attrs.type}</b> input type ({attrs.value})
        </p>
        <p>
          <input
            type={attrs.type}
            value={attrs.value}
            onChange={this.onInputChange}
          />
          <label>
            <input
              type="checkbox"
              checked={this.state.fullDate}
              onChange={this.updateFullDate}
            />{' '}
            Switch type
          </label>
        </p>
      </div>
    );
  }

  inputAttrs() {
    if (this.state.fullDate) {
      return {
        type: 'datetime-local',
        value: this.state.date.toISOString().replace(/\..*Z/, ''),
      };
    } else {
      return {
        type: 'date',
        value: this.state.date.toISOString().replace(/T.*/, ''),
      };
    }
  }

  onInputChange = ({target: {value}}) => {
    const date = value ? new Date(Date.parse(value)) : startDate;
    this.setState({date});
  };

  updateFullDate = () => {
    this.setState({
      fullDate: !this.state.fullDate,
    });
  };
}

export default SwitchDateTestCase;

Domain

Subdomains

Frequently Asked Questions

What does switch-date-test-case.js do?
switch-date-test-case.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What files import switch-date-test-case.js?
switch-date-test-case.js is imported by 1 file(s): index.js.
Where is switch-date-test-case.js in the architecture?
switch-date-test-case.js is located at fixtures/dom/src/components/fixtures/date-inputs/switch-date-test-case.js (domain: BabelCompiler, subdomain: Optimization, directory: fixtures/dom/src/components/fixtures/date-inputs).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free