Vaom
Vaom

Reputation: 21

React Native JS: Hash history needs a DOM

I am creating mobile app whit react native. I want to transerf web app on moblie. I have error:

 E/ReactNativeJS: Hash history needs a DOM

Upvotes: 1

Views: 1056

Answers (1)

Paul S
Paul S

Reputation: 36787

You will have to use an in-memory history in order to use React Router with React Native.

In v2/3 you will have to create your history instances using createMemoryHistory

var history = createMemoryHistory()

const App = () => (
  <Router history={history} routes={...} />
)

v4 of React Router provides a <MemoryRouter> component that will create an in-memory history for you.

const App = () => (
  <MemoryRouter>
    <View>...</View>
  </MemoryRouter>
)

Upvotes: 1

Related Questions