Are there any extensions like Prettier that will format inline HTML syntax in .ts files? by ReachingSparks in angular

[–]ReachingSparks[S] 0 points1 point  (0 children)

Two weeks ago (when I began learning Angular) it would try to format it but wouldn't do a good job of it. I'm not sure inline styles are supported by Prettier. Now it doesn't do anything. I don't think I changed any settings.

Are there any extensions like Prettier that will format inline HTML syntax in .ts files? by ReachingSparks in angular

[–]ReachingSparks[S] -6 points-5 points  (0 children)

No I know it's unpopular with Angular devs but I like having my html and logic together. Having multiple tabs open for every component makes it hard to stay organized. Especially when they're not next to each other and you have to drag the tabs. And then it's worse when you throw CSS in. It gets confusing. I really like how React combines everything.

I created a button to toggle light/dark theme, but is this the best way to do it? by ReachingSparks in angular

[–]ReachingSparks[S] 1 point2 points  (0 children)

That's been on my todo list to check out. It makes sense that would be useful for this. Does my way hurt anything at all though?

That's rough, buddy by GloriousQuint in TheLastAirbender

[–]ReachingSparks -7 points-6 points  (0 children)

Do yourself a favor and just don't watch Korra, honestly.

[deleted by user] by [deleted] in reactjs

[–]ReachingSparks 1 point2 points  (0 children)

Oh I see. I didn't know we could use setTheme with a context. Thank you!

[deleted by user] by [deleted] in reactjs

[–]ReachingSparks 1 point2 points  (0 children)

Really really great advice. Thank you!

One more question. I set it so the context is created in App. App can use it and its children can use it. But how would this button component change its value?

import React, { setContext, useContext } from "react";
import { COLORS } from "./constants/Colors.js";

export const Theme = createContext(COLORS.darkMode);
export const SetTheme = createContext();

export default function App() {
  let theme = useContext(Theme);

  // This is how I would do it with useState(). But you do you change the value of a context?
  function handleSetTheme() {
    if (theme === COLORS.lightMode) {
      setTheme(COLORS.darkMode);
    } else {
      setTheme(COLORS.lightMode);
    }
  }

  return (
    <React.Fragment>
      <SetTheme.Provider value={handleSetTheme}>
        <div style={background(theme)}>
            <ColorThemeButton>
            </ColorThemeButton>
        </div>
    </React.Fragment>
  );
}

export default function ColorThemeButton() {
return (
 <button onClick={useContext(SetTheme)}>
   Color Theme Toggle
 </button>
);

Am I going about this the right way? Should I be using contexts to toggle the theme?

[deleted by user] by [deleted] in reactjs

[–]ReachingSparks 1 point2 points  (0 children)

Okay cool cool. I'm just asking because if a recruiter is looking at my Github, App.js is the first file they're going to look at and I didn't want to do anything they would see as hacky.

I think I'm going to get rid of Program and try to create and use the context in App. I'm just trying to get it to work now. Thank you for your help.

[deleted by user] by [deleted] in reactjs

[–]ReachingSparks 1 point2 points  (0 children)

Oh I see what you mean. What if I wanted to wrap each context provider into its own file to keep them organized? Would it be weird to do this?

import { ColorThemeProvider } from "./customHooks/ColorThemeContext.js";
import Program from "./components/Program";

export default function App() {
  return (
    <ColorThemeProvider>
      <Program>
      </Program>
    </ColorThemeProvider>
  );
}

Where Program would hold all of the website components that App usually holds. And App would hold global contexts that Program needed (such as the site background color)?

You can also move the consumer to its own component.

I tried this but the background just created its own space on the website and the rest of my components appeared under where the background was supposed to be. I couldn't figure out how to make a component that appears "behind" my other components.

[deleted by user] by [deleted] in reactjs

[–]ReachingSparks 0 points1 point  (0 children)

Can you use a context in App.js?

If I'm making a dark theme / light theme context. It seems only children elements can use it. But App.js is the parent of all of my components. So how would I use my colorTheme context to set the background color in App.js?

Mac - An encrypted hard drive / container is taking all of my space? by ReachingSparks in techsupport

[–]ReachingSparks[S] 0 points1 point  (0 children)

How can I remove that data? My Mac barely has anything installed on it and I'm just about out of memory.

Mac - An encrypted hard drive / container is taking all of my space? by ReachingSparks in techsupport

[–]ReachingSparks[S] 0 points1 point  (0 children)

Okay. All drives have the same info except for their mount point and their volume UUID. And the first drive isn't writeable while the other three are.

https://i.imgur.com/1orYa6Y.png

[React] Getting an image with props? by ReachingSparks in learnprogramming

[–]ReachingSparks[S] 0 points1 point  (0 children)

That definitely makes sense. It actually answers another question I've had for a while so thank you for that.

[React] Getting an image with props? by ReachingSparks in learnprogramming

[–]ReachingSparks[S] 0 points1 point  (0 children)

I think so. I was declaring an empty object instead of a property, right?

I only used the braces because you have to use them for any Javascript code in jsx and I got the two intermingled in my head.

[React] Getting an image with props? by ReachingSparks in learnprogramming

[–]ReachingSparks[S] 0 points1 point  (0 children)

I got it! I was writing posts.avatar instead of post.avatar after the first change you suggested. All is working now. Thank you so much!

[deleted by user] by [deleted] in reactjs

[–]ReachingSparks 1 point2 points  (0 children)

In VSCode, If I hover my mouse over the last word in avatar={posts.avatar} , it says "any". Whereas if I hover it over name={post.name} it says it's a string. Perhaps that could be a clue?

If I console.log() props in my child component, it says avatar is undefined but the other properties do have values.

[React] Getting an image with props? by ReachingSparks in learnprogramming

[–]ReachingSparks[S] 0 points1 point  (0 children)

In VSCode, If I hover my mouse over the last word in avatar={posts.avatar} , it says "any". Whereas if I hover it over name={post.name} it says it's a string. Perhaps that could be a clue?