微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在reactjs / redux中获得导入/导出错误

如何解决在reactjs / redux中获得导入/导出错误

const removeCart = (productId) => (dispatch) => {
  dispatch({ type: CART_REMOVE_ITEM,payload=productId})
}

export default removeCart

export { addToCart }

正在将其导出为减速器的动作。 我将其导入为

import removeCart,{ addToCart } from '../actions/cartActions';

但是我收到此错误“尝试导入错误:'../ actions / cartActions'不包含认导出(导入为'removeCart')。”

该路由是正确的,因为我已经在使用同一文件中的其他操作。

解决方法

不要在命名的出口处加上括号。

只是:

    ///   - namespace: The namespace in which defines the `id`. New
    ///     namespaces are created by adding an `@Namespace()` variable
    ///     to a ``View`` type and reading its value in the view's body
    ///     method.
    ///   - properties: The properties to copy from the source view.
    ///   - anchor: The relative location in the view used to produce
    ///     its shared position value.
    ///   - isSource: True if the view should be used as the source of
    ///     geometry for other views in the group.
    ///
    /// - Returns: A new view that defines an entry in the global
    ///   database of views synchronizing their geometry.
    ///
    @inlinable public func matchedGeometryEffect<ID>(id: ID,in namespace: Namespace.ID,// << here !!
       properties: MatchedGeometryProperties = .frame,anchor: UnitPoint = .center,isSource: Bool = true) -> some View where ID : Hashable

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。