David McCabe
Transcript from Friday September 4th, 2020
Author of Recoil
#**Q:**What would you think it's the best way for someone who's a junior to learn and get better in a certain field (like React or some other framework) – Grincek
A: Do lots of projects. If you aren't sure which way is a better approach to doing something, try both quickly.
#**Q:**What is the draw of using recoilJS over redux or similar libraries? – dantalksalot
A: Ease of use, makes it easier to create fast apps that have lots of different pieces of state.
#**Q:**When react concurrent mode will be officially released? – ARKA160
A: No official release date. The new facebook.com is running on concurrent. Upcoming releases of React will help with making existing code compatible. You can try Concurrent now using the experimental release (not in production).
#**Q:**Is Redux a must for state management? Or is an app better off without it. – koqkito
A: Is redux a must: No
#**Q:**What are some good projects for a developer who already feels comfortable with react and needs to advance but doesn't know how? – Ozu
A: Try to build more complex projects? I don't know.
#**Q:**What resources did you use to learn react? – antoniodinkins
A: I started learning React when it first came out, the only resources was the official docs, which were pretty good. I was trying to build a single-page UI for a company and just had to learn on the job.
#**Q:**State persistence seems very unstable/in flux right now, which is one of the drawbacks. What's your roadmap for this functionality? – Kimmain
A: There is a temporary API you can use now. We are experimenting with the permanent API. Soon but not sure exactly when.
<aname="#not-react-related" href="#not-react-related-but">#**Q:**Not react related, but what does it take to work for Facebook? – Raeven
A: If you want to know about passing the interview I think there is a lot of information about the process that's published by FB recruiting. When I interviewed the experience was exactly what I was expecting based on the material I was sent.
#**Q:**How frequently do you use useMemo/useCallback in your components and what rules you have for when to use them? Do you automatically use them in most cases? – Josephdo
A: I generally only use these after observing that a child component's rendering is causing a performance problem.
#**Q:**Will Recoil have the ability to integrate with a design platform like Storybook? – TylerSnow
A: I do not know enough about it to say. I would expect so since it's apparently compatible with multiple different view libraries.
#**Q:**What were your experiences hunting for a job as a junior? – Grincek
A: When I was first in the industry I would go to meetups, find people using open-source software who needed some tiny modification done, put in the needed patch, and then they would hire me for contract work. This is probably not the best strategy in a strong job market though.
#**Q:**How are families garbage collected? – frederik.batuna
A: I am currently working on this, hope to release it soon. Meanwhile you can manually delete using useResetRecoilValue.
Oh by the way, I forgot to mention, Recoil 0.0.11 is going to be released very soon. We were planning to release it yesterday but found a significant bug at the last minute. So probably in the next day or two.
Recoil 0.0.11 has much better performance, experimental Concurrent Mode support, and some other improvements. Upcoming releases will then address memory, performance, and syncing with external storage and servers.
#**Q:**How well does Recoil pair with Immer? – parichay28
A: Haven't tried it, expect it's a great pairing.
<aname="#if-youre-going" href="#if-youre-going-to">#**Q:**If you're going to use Recoil, should you manage your entire state there? Are performance implications if you do? If not, how do you decide what goes into "pure local" vs. managed in Recoil? – Thandathere
A: Great question. Using recoil vs local state does have some performance overhead. On the other hand, if you're using transaction observation for app-wide facilities such as persistence and URLs, that only applies to Recoil state.
#**Q:**I’ve seen that React is in the front-line, when we talk about SPA development. Could be React the future of web, like HTML is for the browser? What do you think? – D4vi0h4ck3r
A: React is a language in many ways, it might make sense to implement that language lower in the stack.
#**Q:**What is the reason behind giving everything a unique key in Recoil? Doesn’t this modularity way more difficult? – yuchimake
A: They're used for persistence, logging, debugging, etc. I would like to find a good solution to statically ensure uniqueness, this is a major weakness currently. However, I haven't seen it be a problem in practice even with projects using hundreds of atoms written by many people across different teams.
#**Q:**There are a lot of state management libraries. Each have their own strengths and weaknesses. Can you tell something about the (fundamental) weaknesses of Recoil? When would you not use this? – mees
A: Relay has a much more sophisticated approach to server-owned data. By knowing the queries statically it's possible to start executing queries while the client is still downloading the code. And it can handle mutations. Recoil's async stuff is limited to time-invariant data and fetch-as-you-render.
A: There is no plan to deprecate classes. However, hooks have huge advantages both for the developer ease of use and implementation. I have not known anyone who's really gotten the hang of hooks to ever look back. They do have a substantial learning curve, though.
That being said, I think if you were learning React from the ground up as hooks-only it would be simpler than learning class components. Hooks more closely model how React actually works, making it easier to write non-buggy code.
#**Q:**In one of the early interviews you did, a question was asked about you speaking with the react team and how receptive they were to possibly introducing concepts from recoil into react. How have those discussions progressed since and are there things that you'd like to see coming from that? – Sonicrida
A: React has to work for a much broader class of apps than any specific state library does. Parts of Recoil are not applicable across all apps (e.g. async stuff), while the basic need to share state across components is fairly universal. There has been work to try to make the Context API more flexible which would obviate this need. I don't know when this is going to happen, though. The Concurrent Mode is an area where the React team is doing a lot of work to make it feasible for more apps. I'm really excited about the work there. We'll continue to see some incredible stuff unlocked by that project in the long term.
#**Q:**When you were first started working on Recoil (early), how did you manage tasks/hitting goals when working with 1-2 people? Is a TODO.md file with a to-do list good enough or was there something a bit more sophisticated that helped you manage things in the long run? – dilraj
A: Coordinating work: at FB we use Workplace by Facebook, it's a great product http://workplace.com/
#**Q:**What is the best use-case for selectors and would what is the benefit of using over handling that logic in your component? – cagethem
A: Advantage of selectors versus handling in component (which I take to mean having a memoized value in the component that you recompute when certain props change): Selector graph can hit different parts of the React tree rather than only whole subtrees. It can also change shape: You can have a conditional dependency. This is hard to do otherwise because of the Rules of Hooks. (Selectors can be less restrictive because they are pure functions)
#**Q:**Is there a suggested naming convention for keys to ensure uniqueness? – Amr
A: You can prefix by module or product area. If prefixes are too specific it can make extra work when refactoring, if you need your keys to be stable across time.
#**Q:**Did you build Recoil as part of your work at FB? Is this something you get to for work, or is this purely a side project? – Thandado
A: It was an on-the-job project. We created Recoil in order to help with a specific app internal to FB that had major performance problems. We decided to make it a separate library since we thought it might be useful in other situations, which turned out to be true. Would not have created a state management library if I hadn't had to due to the specific requirements of this app.
#**Q:**What can we expect more from recoil in the coming future (short and long term)? – parichay28
A: Expect better performance and memory management in apps with large atom families. A more robust implementation of async selectors. APIs for developer tools. APIs for synchronizing state with external storage, URLs, servers, etc. A big part of the performance stuff is eliminating places where Recoil copies data structures. Instead we need to share structure.
#**Q:**Is there an ETA for proper React-Native support? The ongoing PR seems to be a dead in the water for a while :frowning: – Kimbit
A: We had some back-and-forth with various people about React Native support, but unfortunately I don't think a consensus emerged about the best way to do it. Nobody has expressed a willingness to maintain it and unfortunately none of us has expertise in it. I would be very happy to merge a PR that people with knowledge of the area agree is a good approach.
<aname="#whats-your-opinion" href="#whats-your-opinion-on">#**Q:**What's your opinion on the future of React Native? – Grincek
A: I don't have any special knowledge of React Native. I know FB continues to invest in it and build important apps and experiences with it. It seems to me that the work React team is doing generally, such as concurrent and a lot of performance-related research, would benefit RN even more.
#**Q:**There was a lot of interesting discourse in the few months after recoil came out where many users thought that it was an official react state management library which seemed to cause some drama on social media and a bit of trouble in regards to Dan and some of the more active team members on social media having to clarify that it's a separate project a ton. Do you feel as though this is something that could've been managed better with the release of recoil and something that should be taken into consideration whenever facebook releases other possible experimental react packages to cause less confusion within the community? – Sonicrida
A: Regarding communication about "officialness": I don't know how this could have been managed better. It seems like a certain small number of people are going to jump to wild conclusions no matter what you say.
#**Q:**Since Recoil seems to be a state management library for exclusively for React, has there been any talks about whether it should come in as a default dependency with create-react-app after hitting npx create-react-app my-app in the future? – green_lantern 🪐
A: I think the majority of apps are fine with just React, so I don't personally see a need for that.
#**Q:**What about recoil integration with Relay? – ARKA160
A: The typical way to use both together is for Recoil atoms to be passed into Relay query variables.
I highly recommend Relay for the types of things it's designed for. They have done a lot of really sophisticated work and it's getting better very quickly. If you haven't used it in a while give it a try.
#**Q:**Will there be work done to reduce Recoil's bundle size in future? – voldemort
A: This was not a goal for the specific apps we were designing with Recoil. If somebody wants to make it smaller-bundled there is probably low-hanging fruit for that.
awaiting more questions, but I guess I'll say more about bundle size. The original use-case for Recoil was apps that download large blobs of data to the client, so there wasn't any gain from optimizing initial page load since we were just going to have to wait a long time for queries. However as more different apps adopt it it makes more sense to try to reduce it.
#**Q:**Any recommendations for other libraries/patterns to use alongside Recoil for – _Mark Mstate _management use-cases that Recoil is not suited for?
A: Use Relay for most server-owned data.
#**Q:**Do you think other front-end libraries are gonna adapt JSX? – Grincek
A: I don't know. I think it's pretty simple to make a plugin to compile JSX to whatever your library needs.
#**Q:**How is your current experience working with Facebook? Is the work fast paced or is it more demanding now that many people are working remotely? – Poot
A: Cannot recommend FB highly enough as an employer. You get to work with people (not just engineers but also management, ops, facilities, etc.) that are both highly competent and well-aligned. I have not found it to be high stress at all. Rather, the ability to move really quickly feels terrific.
If you're thinking about applying to work at FB, do it. Study hard and then give the interview a shot. I don't think you'll be sorry.
By the way, the interview process at FB is based on the ability to write real practical code, not textbook problems.
For the UIE/front-end recruitinng pipeline, you get questions about building good performant UIs in the browser.
#**Q:**What was the toughest thing or challenge that you faced while building Recoil? – Spark
A: The most technically challenging thing with Recoil has been supporting changeable selector dependencies. This has been the cause of most difficult bugs in Recoil and is very hard to think about. I mean that you can do:
if (get(a)) {
return get(b);
} else {
return get(c);
}
and your selector will be subscribed to only b or only c, according to whether a is true.
#**Q:**Any tip for aspiring state library authors about concurrent mode and useMutableStore — have you had much trouble with the APIs? – jfinity
A: useMutableSource is quite easy to use and actually made Recoil a lot simpler versus what we were doing before.