【问题标题】:Invariant Violation: 29 on react apollo grapql不变违规:29 on react apollo graphql
【发布时间】:2022-02-18 07:35:05
【问题描述】:

这个错误是什么意思? Invariant Violation: 29 (see https://github.com/apollographql/invariant-packages) 我是否遗漏了触发此错误的代码?有谁知道这个错误是什么意思?,当我尝试将LocationSearch 组件导入到我的index.js 时遇到了这个错误

import { LocationSearch } from '../component/LocationSearch';

<LocationSearch
   freeSolo
   withIcon={false}
/>

../component/LocationSearch.js

import { GETSTUDENTLOCATION } from '../../utils/location.gql';
const propTypes = {
   withIcon: PropTypes.bool,
}
const defaultProps = {
   withIcon: true,
}
const LocationSearch = ({
   withIcon,
})=>{
  const [getStudentLocations] = useQuery(GETSTUDENTLOCATION);

  const onChangeHandler = (e, value) => {
    onChange(value);
    const { valid, error } = isValid(value);
    if (!valid) {
      onError(error, value);
    }

    setOpen(false);
    setOptions([]);
  };

  const onInputChangeHandler = (e, inputString, reason) => {
      setKeyUpTimeOut(
        setTimeout(async () => {
          setLoading(true);
          const { data: searchLocation } = await getLocations({
            variables: {
              placeSearch: {
                address: inputString,
              },
            },
          });
          setLoading(false);
          setOptions(searchLocation.findLocationByAddress || []);
          setOpen(true);
        }, 500)
      );
  };


<Autocomplete
    onChange={onChangeHandler}
    onClose={onClose}
    onInputChange={onInputChangeHandler}
    open={open}
    options={uniqBy(
       multiple
       ? [...options, ...value]
       : value
       ? [...options, value]
       : options,
       'name'
    )}
/>
}

../../utils/location.gql

export const GETSTUDENTLOCATION = gql`
  query SearchStudentLocation($placeSearch: Location!) {
    searchstudentlocation(placeSearch: $placeSearch) {
      student_name
      address {
        street1
        street2
        city
        barangay
        houseNumber
        port
      }
      remarks
    }
  }
`;

【问题讨论】:

  • 对不起@ElliottFrisch

标签: javascript reactjs material-ui apollo apollo-client


【解决方案1】:

我认为是因为你的apollo-client的版本

【讨论】:

    猜你喜欢
    • 2021-02-13
    • 2022-10-18
    • 1970-01-01
    • 2018-07-07
    • 2017-02-27
    • 1970-01-01
    • 1970-01-01
    • 2016-06-10
    • 2018-10-04
    相关资源
    最近更新 更多