1
다음과 같은 문제가 있습니다. 내 redux 저장소에 searchString
을 업데이트 할 때마다 Griddle에 전달하는 CustomFilterConnectedComponent
이 전달되고 왜 이런 일이 발생하는지 이해하지 못합니다. .customFilterComponent의 Griddle v1.9 inputbox가 포커스를 잃습니다
멍청한 구성 요소 :
import { connect } from "react-redux";
const CustomFilterComponent = (props) => (
<input
value={props.searchString}
onChange={(e) => { props.setSearchString(e.target.value); }}
/>
);
스마트 구성 요소 :
const CustomFilterConnectedComponent = connect(
(state: TRootReducerState) => {
return ({
searchString: state.searchString,
});
},
(dispatch: any) => ({
setSearchString: (e) => dispatch(setSearchStringActionCreator(e))
})
)(CustomFilterComponent);
사용법 : 여기
class SomePage extends React.Component<Props, {}> {
render() {
return (
<div>
{/* keypress - everything is ok, value is updated & focus is not lost*/}
<CustomFilterConnectedComponent/>
<Griddle
components={{
/* keypress - value is updated, but focus lost */
Filter: CustomFilterConnectedComponent
}}
storeKey="griddleStore"
data={this.props.requests as any}
/>
</div>
);
}
}
이
는 documentation에 따라 내 코드입니다 github에 관한 문제에 link입니다.