user16861088
user16861088

Reputation:

Writing react native with typescript with redux and react-redux

I was wondering when I write redux action, reducers and store using typescript in React Native, should I give it an extension of .tsx or it can be .js only?

For instance this is my store.tsx file look like this:

import {createStore, applyMiddleware, combineReducers} from 'redux';
import {composeWithDevTools} from 'redux-devtools-extension';
import thunk from 'redux-thunk';

import newsReducer from './reducers/newsReducer';

const rootReducer = combineReducers({
  news: newsReducer,
});

const middleware = composeWithDevTools(applyMiddleware(thunk));

export default createStore(rootReducer, middleware);

Should my files become all tsx extension in this case?

Upvotes: 0

Views: 92

Answers (1)

Vishal Nai
Vishal Nai

Reputation: 288

If you are not using any Typescript code into that component than you don't need to make it .tsx but whenever you are using any Typescript functionality at that time you should, because typescript compiler accept .ts file and transpiled into JS,

And one suggestion if you have used .tsx everywhere in projects so i would suggest to use .tsx only to manage code structure properly.

So you can use accordingly

Upvotes: 1

Related Questions