简体   繁体   English

`react-hover` npm软件包不在生产版本中,但在开发中运行良好

[英]`react-hover` npm package not in production build but working fine in development

I want to make use of the npm package react-hover (here's the github link ) in my project and when I develop locally in dev build it works just fine. 我想在我的项目中使用npm包react-hover (这是github链接 ),当我在dev build中进行本地开发时,它可以正常工作。 When I run the npm run build command and serve the production version the components I want to show in the <ReactHover> object don't render on the page. 当我运行npm run build命令并提供生产版本时,要显示在<ReactHover>对象中的组件不在页面上呈现。

I started the project using create-react-app I serve the production version locally using the npm package serve . 我使用create-react-app启动了项目,并使用npm包serve在本地提供了生产版本。

I will share all the files of my project since it's nothing spectacular, here are all files on a public repo . 我将共享项目的所有文件,因为这没什么大不了的,这里是公共仓库中的所有文件

I haven't really been able to find this issue anywhere else so any insight would be appreciated. 我真的无法在其他任何地方找到此问题,因此我们将不胜感激。

You can simply use CSS to do that. 您可以简单地使用CSS来做到这一点。 Define two divs, one with id="hover-selector-parent" and another with id="hover-selector-child". 定义两个div,其中一个id为“ =“ hover-selector-parent”,另一个为id =“ hover-selector-child”。

Then configure your CSS file to handle the event - 然后配置您的CSS文件以处理事件-

#hover-selector-parent:hover~#hover-selector-child{
  display:block;
}

#hover-selector-child{
  display: none;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React NPM 包(Dragula)可用于开发但不能用于生产 - React NPM package(Dragula) works in development but not in production React 样式组件在生产中导致构建错误,但在开发中运行良好 - React styled component causes build error in production, but runs fine in development 检测React / ReactDOM开发/生产构建 - Detect React/ReactDOM development/production build React 组件未在生产构建中呈现,但在开发构建中按预期工作 - React component not rendering in production build but works as expected in development build webpack production build 总是返回 这个页面使用的是 React 的开发 build - Webpack production build always returns This page is using the development build of React React API 在开发中调用工作并在生产构建中失败 - React API calls work in development and fail in production build React Native:生产构建上的箭头功能不起作用 - React Native : Arrow function on production build not working React 项目构建生产在 Xampp 中不起作用 - React project build production is not working in Xampp npm package with @emption/react with vite 未按预期工作 - npm package with @emption/react with vite not working as expected React 应用程序无法通过其请求在生产中访问我的快速应用程序,但在开发中运行良好 - React app can't reach my express app in production with its requests but works fine in development
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM