0

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?

1
  • If it doesn't include any actual JSX then, just use a .ts or .js extension depending on if it is JS or TypeScript. Commented Sep 30, 2021 at 12:37

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.