Tengo un formulario, y estoy tratando de hacer una publicación.
En el formulario cuando se envía, llamo a la función saveEntity:
import { createEntity } from './realmUser-reducer' export interface IRealmUserUpdateProps extends StateProps, DispatchProps, RouteComponentProps<{ id: string }> { } export const RealmUserUpdate = (props: IRealmUserUpdateProps) => { interface LocationState { userId: number | string } const location = useLocation<LocationState>() const saveEntity = (event, errors, values) => { if (errors.length === 0) { const entity = { realm: {id: values.realm}, user: {userId: location.state} } props.createEntity(entity) // this error: Uncaught (in promise) TypeError: props.createEntity is not a function } } return(//.....) const mapStateToProps = (storeState: IRootState) => ( { }); const mapDispatchToProps = { createEntity } type StateProps = ReturnType<typeof mapStateToProps>; type DispatchProps = typeof mapDispatchToProps; export default connect(mapStateToProps, mapDispatchToProps)(RealmUserUpdate);en mi reductor:
export const createEntity: ICrudPutAction<IRealmUser> = entity => async dispatch => { const result = await dispatch({ type: ACTION_TYPES.CREATE_REALMUSER, payload: axios.post(apiUrl, cleanEntity(entity)), }); return result; };el modelo que creé:
export interface IRealmUser { id?: string | number | null; user?: { perCod?: any } realm?: { id?: number | string | null } } export const defaultValue: Readonly<IRealmUser> = {};Entonces mi problema es que cuando estoy tratando de hacer la publicación recibo un error:
el error: no capturado (en promesa) TypeError: props.createEntity no es una función
sobre props.createEntity(entity)
EDITAR1:
Agregando console.log (accesorios)
history: { "length": 50, "action": "PUSH", "location": { "pathname": "/realmUser/new", "state": 156001, "search": "", "hash": "", "key": "2dwfy5" } } location:{ "pathname": "/realmUser/new", "state": 156001, "search": "", "hash": "", "key": "2dwfy5" } match: { "path": "/realmUser/new", "url": "/realmUser/new", "isExact": true, "params": {} }