1. react table editable
https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/editable-data
https://react-table.tanstack.com/docs/examples/editable-data
2. react input focus blur event
const inputRef = useRef();
const handleKeyPress = (e) => {
if(e.key === 'Enter') {
console.log('enter')
inputRef.current.blur();
}
}
return <input
value={value}
onChange={onChange}
onBlur={onBlur}
css={inputStyle}
onKeyPress={handleKeyPress}
ref={inputRef}
/>
3. react-table fixed column
http://www.recompile.in/2019/11/react-fixed-table-header-code-without.html
https://codesandbox.io/s/react-table-fixed-columns-official-kowzlm5jp7
https://gojjc.tistory.com/entry/reactReact-Table-지정-컬럼-고정시키하기
4. table view 에 border넣기
https://www.codingfactory.net/10510
5. editable table에서 input타입을 동적으로 렌더링 하고 싶음
// import makeData from './makeData'
const EditableCell = ({
value : initialValue,
row : {index},
column : {id},
updateMyData,
}) => {
const [value, setValue ] = useState(initialValue);
const [type, setType] = useState('type');
const inputRef = useRef();
const onChange = e => {
setValue(e.target.value);
}
const onBlur = () => {
updateMyData()
}
const handleKeyPress = (e) => {
if(e.key === 'Enter') {
inputRef.current.blur();
}
}
useEffect(()=>{
setValue(initialValue)
setType(typeof value)
},[initialValue])
return <input
value={value}
onChange={onChange}
onBlur={onBlur}
css={inputStyle}
onKeyPress={handleKeyPress}
ref={inputRef}
type={type}
/>
}
728x90
'TIL' 카테고리의 다른 글
[TIL] 20211209 react-query/select tag value/react-table-sticky (0) | 2021.12.14 |
---|---|
[TIL] 20211208 react hook form yup/ position absolute/classnames (0) | 2021.12.10 |
[TIL] 20211206 react 라이브러리들 (0) | 2021.12.08 |
[TIL] 20211203 react table/ react css / emotion.js / @emotion.react (0) | 2021.12.08 |
[TIL] 20211202 redux toolkit / moments.js/ react hook error (0) | 2021.12.06 |