# 无法preventDefault

Chrome 51默认设定注入`scroll` 事件的`passive` 变量为`true` 。而React的设计原则是跟随chrome的设定。因此在React设计的**合成事件(**&#x53;yntheticEven&#x74;**)**,  无法实现 `e.preventDefault()`&#x20;

目前的解决方案是，自行绑定dom元素，添加`addEventListener`&#x20;

```javascript
import React, { useRef, useEffect } from 'react'

const BlockPageScroll = ({ children }) => {
  const scrollRef = useRef(null)
  useEffect(() => {
    const scrollEl = scrollRef.current
    scrollEl && scrollEl.addEventListener('wheel', stopScroll)
    return () => {
      scrollEl && scrollEl.removeEventListener('wheel', stopScroll)
    }
  }, [])
  const stopScroll = e => e.preventDefault()
  return (
    <div ref={scrollRef}>
      {children}
    </div>
  )
}

const Main = () => (
  <BlockPageScroll>
    <div>Scrolling here will only be targeted to inner elements</div>
  </BlockPageScroll>
)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mm.ricky.moe/framework/react/wu-fa-preventdefault.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
