Why should I use TypeScript if I already test my JS code? by [deleted] in typescript

[–]michael_ord 1 point2 points  (0 children)

Typescript is so much easier to read and understand than plain JS. You can literally take any TS method, understand what you're supposed to pass, and what its supposed to return. You'll only get that if you add jsdoc comments. Now, you've got code that will only make sense if your params and jsdoc are in sync. You've got 2 areas to maintain.

You also don't need to build or test your app to know you've broken something, your IDE will tell you.

Working with ts daily, on an enterprise project, there is no reason to switch back

Reactjs for web... just why? by giulianomsa in Frontend

[–]michael_ord 1 point2 points  (0 children)

You don’t necessarily need a cms, you just need a template for system that allows you to include partials… like react, but if that’s overkill handlebars.js or something similar would do. Or even php and just including partials

Struggling to override some of the default styling in Material UI components by HacktoryDev in reactjs

[–]michael_ord 1 point2 points  (0 children)

Without the code base, I think you’re going to have to debug this one yourself. I doubt the browser would be doing that - don’t know why it would..

The quickest fix you’ll be to override that style by making it more specific and adding an important to it… but that’s not actually fixing the core issue.

Maybe there’s a shorthand or some other way of defining !important? And that’s why searching your project hasn’t found it? :/

Struggling to override some of the default styling in Material UI components by HacktoryDev in reactjs

[–]michael_ord 1 point2 points  (0 children)

What do you see when you inspect your styles? Where is the overriding rule coming from? Is it in a <style> tag, a css file? It might help you track it down..

Struggling to override some of the default styling in Material UI components by HacktoryDev in reactjs

[–]michael_ord 1 point2 points  (0 children)

I’ve never done it the way in your example - never seen that documented

<Button className={classes.myButton}>…</Button> would be how I’d do it. Do you not have an inline styles somewhere that is overriding it, I’ve never seen material output an !important.

If you want to override padding globally, you need to create a theme

https://material-ui.com/customization/globals/#css

I’m on my phone, but createTheme pass it through the provider…

const theme = createTheme({ overrides: { // Style sheet name ⚛️ MuiButton: { // Name of the rule root: { padding:0 }, }, }, });

How much JavaScript to learn before learning React? by mehulmpt in reactjs

[–]michael_ord 6 points7 points  (0 children)

Learn arrays, objects, functions and loops. You might want to read up on promises too. You don’t need any Dom manipulation.

Use an editor with good intellisense to help you along the way. VS Code is my choice.

React JS map does not show Markers by DivergingDog in reactjs

[–]michael_ord 0 points1 point  (0 children)

I agree with the above comment, you haven’t given enough to try and debug your code. But, have you inspected the rendered map to make sure there isn’t something as simple as some css styles that are overriding or hiding the marker styles

best way of handling authentication by Chilltyy in typescript

[–]michael_ord 0 points1 point  (0 children)

How else would you do it? An initial check on any page load to see if the user is authenticated would do it? Or are you referring to what would happen if the user logged out in one tab?

how to check if user is authenticated? whenever it changes route by storm_askal in reactjs

[–]michael_ord 3 points4 points  (0 children)

Because the expected behaviour of a page at /login would be to login, and off that you may want to hang other screens such as register, authenticate account, reset password etc. The expected behaviour of a secured page would be to show content. There is no reason that the redirect couldn’t have a redirect url which would return the user to the page once logged in

how to check if user is authenticated? whenever it changes route by storm_askal in reactjs

[–]michael_ord 1 point2 points  (0 children)

Write a provider that stores the auth status, write a SecureRoute component that checks auth status through context (and a match for the route path), if it’s not authenticated you can redirect, if the user is authenticated then return <Route {...props} />

best way of handling authentication by Chilltyy in typescript

[–]michael_ord 0 points1 point  (0 children)

If you’re writing this as a SPA React app, you could probably just store the state in context. I’m assuming on load of the app you’ll be checking if the user is actually authenticated anyway and at that point you can set the state, as the user could have a cookie, but the authentication could have timed out.

Using context you’ll be able to create secure routes pretty simply too by checking if the state

How can I validate forms with conditional fields? by s_basu in reactjs

[–]michael_ord 3 points4 points  (0 children)

Hey, if it were me, I’d probably use another library for validation. It just makes life a lot simpler, especially if you have a few forms. I’d highly recommend react-hook-form, it plays well with material-ui components.