前提・実現したいこと
React.jsで二つのセレクトボックスから値を取得して検索をする画面を実装したのですが、
セレクトボックスを開いた時にブラウザのデバッグコンソールを開いてみると以下のようなエラーが出てしまいます。動作状は特に問題はお起きていないので問題はないのですができればエラーをなくしたいと思っています。ご教授のほどよろしくお願い致します。
発生している問題・エラーメッセージ
Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Transition which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://fb.me/react-strict-mode-find-node in div (created by ForwardRef(Paper)) in ForwardRef(Paper) (created by WithStyles(ForwardRef(Paper))) in WithStyles(ForwardRef(Paper)) (created by Transition) in Transition (created by ForwardRef(Grow)) in ForwardRef(Grow) (created by TrapFocus) in TrapFocus (created by ForwardRef(Modal)) in div (created by ForwardRef(Modal)) in ForwardRef(Portal) (created by ForwardRef(Modal)) in ForwardRef(Modal) (created by ForwardRef(Popover)) in ForwardRef(Popover) (created by WithStyles(ForwardRef(Popover))) in WithStyles(ForwardRef(Popover)) (created by ForwardRef(Menu)) in ForwardRef(Menu) (created by WithStyles(ForwardRef(Menu))) in WithStyles(ForwardRef(Menu)) (created by ForwardRef(SelectInput)) in ForwardRef(SelectInput) (created by ForwardRef(InputBase)) in div (created by ForwardRef(InputBase)) in ForwardRef(InputBase) (created by WithStyles(ForwardRef(InputBase))) in WithStyles(ForwardRef(InputBase)) (created by ForwardRef(Input)) in ForwardRef(Input) (created by WithStyles(ForwardRef(Input))) in WithStyles(ForwardRef(Input)) (created by ForwardRef(Select)) in ForwardRef(Select) (created by WithStyles(ForwardRef(Select))) in WithStyles(ForwardRef(Select)) (at Search.js:44) in div (created by ForwardRef(FormControl)) in ForwardRef(FormControl) (created by WithStyles(ForwardRef(FormControl))) in WithStyles(ForwardRef(FormControl)) (at Search.js:42) in form (at Search.js:41) in Search (at App.js:73) in div (at App.js:71) in App (at src/index.js:9) in StrictMode (at src/index.js:8)
該当のソースコード
import React, { useState } from "react"; import { MenuItem, FormControl, InputLabel, Select } from '@material-ui/core'; const Search = (props) => { const current_year = (new Date()).getFullYear(); const current_cour = Math.ceil((new Date()).getMonth() / 3); const [year, setYear] = useState(current_year); const [cour, setCour] = useState(current_cour); const years = []; for (var y = current_year; y >= 2014; y--) { years.push(<MenuItem key={y} value={y}>{y}年</MenuItem>); } const cours = []; const cours_detail = ['1期(冬期)', '2期(春期)', '3期(夏期)', '4期(秋期)']; for (var i = 0; i < cours_detail.length; i++) { cours.push(<MenuItem key={i+1} value={i+1}>{cours_detail[i]}</MenuItem>); } const handleYearChanges = (e) => { setYear(e.target.value); } const handleCourChanges = (e) => { setCour(e.target.value); } const callSearchFunction = (e) => { e.preventDefault(); console.log(year); console.log(cour) // props.search(year, cour); } return ( <> <form className="search"> <FormControl> <InputLabel shrink htmlFor="year-helper">西暦</InputLabel> <Select value={year} onChange={handleYearChanges} inputProps={{ name: 'year', id: 'year-helper', }} > {years} </Select> </FormControl> <FormControl> <InputLabel shrink htmlFor="cour-helper">クール</InputLabel> <Select value={cour} onChange={handleCourChanges} inputProps={{ name: 'cour', id: 'cour-helper', }} > {cours} </Select> </FormControl> <input onClick={callSearchFunction} type="submit" value="SEARCH" /> </form> </> ); } export default Search;
補足情報(FW/ツールのバージョンなど)
react:16.13.1,
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/03/26 11:24